public function ScheduledUpdateTypeForm::form in Scheduled Updates 8
Gets the actual form array to be built.
Overrides ScheduledUpdateTypeBaseForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ ScheduledUpdateTypeForm.php, line 32 - Contains \Drupal\scheduled_updates\Form\ScheduledUpdateTypeForm.
Class
- ScheduledUpdateTypeForm
- Class ScheduledUpdateTypeForm.
Namespace
Drupal\scheduled_updates\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $this->entity
->label(),
'#description' => $this
->t("Label for the Scheduled update type."),
'#required' => TRUE,
'#weight' => -110,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $this->entity
->id(),
'#machine_name' => array(
'exists' => '\\Drupal\\scheduled_updates\\Entity\\ScheduledUpdateType::load',
),
'#disabled' => !$this->entity
->isNew(),
'#weight' => -100,
);
$default_type = $this
->getCurrentEntityType($form_state);
$disabled = !$this->entity
->isNew();
$form['update_entity_type'] = [
'#type' => 'select',
'#title' => $this
->t('Entity Type'),
'#description' => $this
->t('The entity type to update. This <strong>cannot</strong> be changed after this type is created.'),
'#options' => $this
->entityTypeOptions(),
'#default_value' => $default_type,
'#required' => TRUE,
// @todo why doesn't this work?
'#disabled' => $disabled,
'#weight' => -90,
];
// @todo Remove when bug is fixed.
if (!$form['update_entity_type']['#disabled']) {
// Just to duplicate issues on d.o for now.
$form['update_entity_type']['#description'] .= '<br /><strong>**KNOWN BUG**</strong> : Ajax error when selecting one entity type and then selecting another: https://www.drupal.org/node/2643934';
}
$form['update_entity_type'] += $this
->typeDependentAjax();
$form['field_map'] = $this
->createFieldMapElements();
/* You will need additional form elements for your custom properties. */
return $form;
}