You are here

public function StatusTypeForm::form in Heartbeat 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

modules/statusmessage/src/Form/StatusTypeForm.php, line 46

Class

StatusTypeForm
Class StatusTypeForm.

Namespace

Drupal\statusmessage\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $status_type = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $status_type
      ->label(),
    '#description' => $this
      ->t("Label for the Status type."),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $status_type
      ->id(),
    '#machine_name' => array(
      'exists' => '\\Drupal\\statusmessage\\Entity\\StatusType::load',
    ),
    '#disabled' => !$status_type
      ->isNew(),
  );
  $form['media'] = array(
    '#type' => 'checkbox',
    '#description' => 'This status message contains media',
    '#default' => $status_type
      ->getMedia(),
  );
  $form['mime'] = array(
    '#type' => 'select',
    '#description' => 'The MIME Type of the media contained in this status message',
    '#options' => array(
      $this->mimeTypes,
    ),
    '#default' => $status_type
      ->getMime(),
  );

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