You are here

public function BadgeTypeForm::form in User Badges 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/BadgeTypeForm.php, line 23
Contains \Drupal\user_badges\Form\BadgeTypeForm.

Class

BadgeTypeForm
Class BadgeTypeForm.

Namespace

Drupal\user_badges\Form

Code

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

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