You are here

public function BrowserTypeForm::form in Paragraphs Browser 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/BrowserTypeForm.php, line 16

Class

BrowserTypeForm
Form controller for paragraph type forms.

Namespace

Drupal\paragraphs_browser\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $paragraphs_type = $this->entity;
  $form['#title'] = t('Edit %title paragraph type', array(
    '%title' => $paragraphs_type
      ->label(),
  ));
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $paragraphs_type
      ->label(),
    '#description' => $this
      ->t("Label for the Paragraphs Browser type."),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $paragraphs_type
      ->id(),
    '#machine_name' => array(
      'exists' => 'paragraphs_browser_type_load',
    ),
    '#disabled' => !$paragraphs_type
      ->isNew(),
  );

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