You are here

public function FlippingBookTypeForm::form in Flipping Book 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/FlippingBookTypeForm.php, line 20

Class

FlippingBookTypeForm
Class FlippingBookTypeForm.

Namespace

Drupal\flipping_book\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $flipping_book_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $flipping_book_type
      ->label(),
    '#description' => $this
      ->t("Label for the Flipping Book type."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $flipping_book_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\flipping_book\\Entity\\FlippingBookType::load',
    ],
    '#disabled' => !$flipping_book_type
      ->isNew(),
  ];
  $location = $flipping_book_type
    ->get('location');
  $form['location'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Import location'),
    '#options' => $this
      ->getImportLocations(),
    '#description' => $this
      ->t('Choose where you want to import your flipping books.'),
    '#required' => TRUE,
    '#default_value' => $location,
    '#disabled' => !empty($location),
  ];
  return $form;
}