public function DraggableListBuilder::buildForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php \Drupal\Core\Config\Entity\DraggableListBuilder::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
4 calls to DraggableListBuilder::buildForm()
- FilterFormatListBuilder::buildForm in core/
modules/ filter/ src/ FilterFormatListBuilder.php - Form constructor.
- LanguageListBuilder::buildForm in core/
modules/ language/ src/ LanguageListBuilder.php - Form constructor.
- SearchPageListBuilder::buildForm in core/
modules/ search/ src/ SearchPageListBuilder.php - Form constructor.
- VocabularyListBuilder::buildForm in core/
modules/ taxonomy/ src/ VocabularyListBuilder.php - Form constructor.
4 methods override DraggableListBuilder::buildForm()
- FilterFormatListBuilder::buildForm in core/
modules/ filter/ src/ FilterFormatListBuilder.php - Form constructor.
- LanguageListBuilder::buildForm in core/
modules/ language/ src/ LanguageListBuilder.php - Form constructor.
- SearchPageListBuilder::buildForm in core/
modules/ search/ src/ SearchPageListBuilder.php - Form constructor.
- VocabularyListBuilder::buildForm in core/
modules/ taxonomy/ src/ VocabularyListBuilder.php - Form constructor.
File
- core/
lib/ Drupal/ Core/ Config/ Entity/ DraggableListBuilder.php, line 106 - Contains \Drupal\Core\Config\Entity\DraggableListBuilder.
Class
- DraggableListBuilder
- Defines a class to build a draggable listing of configuration entities.
Namespace
Drupal\Core\Config\EntityCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form[$this->entitiesKey] = array(
'#type' => 'table',
'#header' => $this
->buildHeader(),
'#empty' => t('There is no @label yet.', array(
'@label' => $this->entityType
->getLabel(),
)),
'#tabledrag' => array(
array(
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
),
),
);
$this->entities = $this
->load();
$delta = 10;
// Change the delta of the weight field if have more than 20 entities.
if (!empty($this->weightKey)) {
$count = count($this->entities);
if ($count > 20) {
$delta = ceil($count / 2);
}
}
foreach ($this->entities as $entity) {
$row = $this
->buildRow($entity);
if (isset($row['label'])) {
$row['label'] = array(
'#markup' => $row['label'],
);
}
if (isset($row['weight'])) {
$row['weight']['#delta'] = $delta;
}
$form[$this->entitiesKey][$entity
->id()] = $row;
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
'#button_type' => 'primary',
);
return $form;
}