public function AuthorPaneFormBase::buildForm in Author Pane 8.3
Overrides Drupal\Core\Entity\EntityFormController::form().
Builds the entity add/edit form.
Parameters
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
Return value
array An associative array containing the AuthorPane add/edit form.
Overrides EntityForm::buildForm
File
- src/
Form/ AuthorPaneFormBase.php, line 57 - Contains \Drupal\author_pane\Form\AuthorPaneFormBase.
Class
- AuthorPaneFormBase
- Class AuthorPaneFormBase.
Namespace
Drupal\author_pane\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get anything we need from the base class.
$form = parent::buildForm($form, $form_state);
/** @var \Drupal\author_pane\Entity\AuthorPane $authorPane */
$authorPane = $this->entity;
// The Author Pane label.
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $authorPane
->label(),
'#description' => $this
->t("Author Pane label."),
'#required' => TRUE,
);
// The Author Pane machine name.
$form['id'] = array(
'#type' => 'machine_name',
'#title' => $this
->t('Machine name'),
'#default_value' => $authorPane
->id(),
'#machine_name' => array(
'exists' => array(
$this,
'exists',
),
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'error' => 'The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".',
),
'#disabled' => !$authorPane
->isNew(),
);
// The Author Pane description.
$form['description'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#maxlength' => 255,
'#default_value' => $authorPane
->getDescription(),
'#description' => $this
->t("Notes about how or where this Author Pane will be used."),
'#required' => FALSE,
);
return $form;
}