You are here

public function RngContactTypeForm::buildForm in RNG Contact 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/RngContactTypeForm.php, line 18

Class

RngContactTypeForm
Form controller for contact types.

Namespace

Drupal\rng_contact\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $rng_contact_type = $this->entity;
  if (!$rng_contact_type
    ->isNew()) {
    $form['#title'] = $this
      ->t('Edit registrant type %label', [
      '%label' => $rng_contact_type
        ->label(),
    ]);
  }
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $rng_contact_type
      ->label(),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#title' => $this
      ->t('Machine name'),
    '#default_value' => $rng_contact_type
      ->id(),
    '#machine_name' => [
      'exists' => [
        $this,
        'exists',
      ],
    ],
  ];
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => $this
      ->t('Description'),
    '#default_value' => $rng_contact_type->description,
  );
  return $form;
}