You are here

public function PersonaTypeForm::form in Drupal PM (Project Management) 4.x

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

modules/pm_persona/src/Form/PersonaTypeForm.php, line 18

Class

PersonaTypeForm
Provides a form for editing a Persona type.

Namespace

Drupal\pm_persona\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $pm_persona_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $pm_persona_type
      ->label(),
    '#description' => $this
      ->t("Label for the Persona type."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $pm_persona_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\pm_persona\\Entity\\PersonaType::load',
    ],
    '#disabled' => !$pm_persona_type
      ->isNew(),
  ];

  /* You will need additional form elements for your custom properties. */
  return $form;
}