Form Factory Kits
This module provides tools to quickly generate Drupal forms by creating reusable form component kits. These kits can be assembled using a fluent API to build complex forms, such as those with vertical tabs, and are compatible with the FormFactory module.
Make custom Drupal forms... faster.
This module provides a service capable of creating FormFactoryKit objects.
Each kit is able to generate an array compatible with Drupal's Render API.
When appended to a FormFactory instance (provided by formfactory module), the kit is used to help create a complete form.
The kits provided by this module are merely covering Form API basics. Collections of Kit objects can be provided by any module.
Example
public function buildFormObject(FormFactoryInterface $form_factory, FormFactoryKitsInterface $kits): void
{
// Optional: the Form State object can be accessed via the Form Factory.
$form_state = $form_factory->getFormState();
// Create VerticalTabsKit & add it to the FormFactory instance.
$tabs = $kits->verticalTabs();
$form_factory->append($tabs);
// Create a "dogs" TabKit & add it to the VerticalTabsKit instance.
$dogsTab = $tabs->createTab('dogs')
->setTitle($this->t('Dogs'));
$dogsTab->append(
$kits->image('dogs_image')
->setTitle($this->t('Image'))
);
$dogsTab->append(
$kits->textarea('dogs_description')
->setTitle($this->t('Description'))
);
$dogsTab->append(
$kits->checkboxes('dogs_attributes')
->setTitle($this->t('Attributes'))
->appendOption(['a' => $this->t('A')])
->appendOption(['b' => $this->t('B')])
->appendOption(['c' => $this->t('C')])
->setDefaultValue(['b'])
);
// Create a "cats" TabKit & add it to the VerticalTabsKit instance.
$tabs->createTab('cats')
->setTitle($this->t('Cats'))
->append($kits->image('cats_image')->setTitle($this->t('Image')))
->append($kits->textarea('cats_description')->setTitle($this->t('Description')));
// Create a SubmitKit & add it to the FormFactory instance.
$form_factory->append($kits->submit());
}
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 2.1.0-beta1 | Pre-release | 10–11 | Adding FormObjectBase class which further streamlines custom form creation. | Dec 13, 2025 | |
| 2.0.0-beta5 | Pre-release | 10–11 | Nov 22, 2025 | ||
| 2.0.0-beta4 | Pre-release | 9–11 | Nov 22, 2025 |