public function CustomPublishingOptionForm::form in Custom Publishing Options 8
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ CustomPublishingOptionForm.php, line 51
Class
- CustomPublishingOptionForm
- Class CustomPublishingOptionForm.
Namespace
Drupal\custom_pub\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $this->entity
->label(),
'#description' => $this
->t("The label for this publishing option."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $this->entity
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\custom_pub\\Entity\\CustomPublishingOption::load',
],
'#disabled' => !$this->entity
->isNew(),
];
$form['publish_under_promote_options'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Place under "Promote options"'),
'#size' => 10,
'#maxlength' => 255,
'#default_value' => $this->entity
->isPublishUnderPromoteOptions(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Description'),
'#maxlength' => 255,
'#default_value' => $this->entity
->getDescription(),
'#description' => $this
->t("Add a description for this publishing option."),
'#required' => TRUE,
];
return $form;
}