You are here

public function BlockGroupContentForm::form in Block Group 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/BlockGroupContentForm.php, line 18

Class

BlockGroupContentForm
Class BlockGroupContentForm.

Namespace

Drupal\blockgroup\Form

Code

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

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