You are here

public function FeedbackMessageTypeForm::form in Feedback 3.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

src/Form/FeedbackMessageTypeForm.php, line 18

Class

FeedbackMessageTypeForm
Class FeedbackMessageTypeForm.

Namespace

Drupal\feedback\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\feedback\Entity\FeedbackMessageType $feedback_message_type */
  $feedback_message_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $feedback_message_type
      ->label(),
    '#description' => $this
      ->t("Label for the Feedback message type."),
    '#required' => TRUE,
  ];
  $form['success_message'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Success message'),
    '#maxlength' => 255,
    '#default_value' => $feedback_message_type
      ->getSuccessMessage(),
    '#description' => $this
      ->t("The message to display on successful submission."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $feedback_message_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\feedback\\Entity\\FeedbackMessageType::load',
    ],
    '#disabled' => !$feedback_message_type
      ->isNew(),
  ];

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