You are here

public function BoardTypeForm::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_board/src/Form/BoardTypeForm.php, line 18

Class

BoardTypeForm
Provides a form for editing a Board type.

Namespace

Drupal\pm_board\Form

Code

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

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