You are here

protected function FormEntityBaseForm::buildConfigurationForm in Flexiform 8

Build the plugin configuration form.

2 calls to FormEntityBaseForm::buildConfigurationForm()
FormEntityAddForm::buildForm in src/Form/FormEntityAddForm.php
Form constructor.
FormEntityEditForm::buildForm in src/Form/FormEntityEditForm.php
Form constructor.

File

src/Form/FormEntityBaseForm.php, line 99

Class

FormEntityBaseForm
Provides a base class for entity forms.

Namespace

Drupal\flexiform\Form

Code

protected function buildConfigurationForm(array $form, FormStateInterface $form_state, FlexiformFormEntityInterface $form_entity = NULL, $namespace = '') {
  $form_state = MultipleEntityFormState::createForForm($form, $form_state);
  $this->formEntity = $form_entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#description' => $this
      ->t('A label for this entity. This is only used in the admin UI.'),
    '#required' => TRUE,
    '#default_value' => $form_entity
      ->getLabel(),
  ];
  if (empty($namespace)) {
    $form['namespace'] = [
      '#type' => 'machine_name',
      '#title' => $this
        ->t('Namespace'),
      '#description' => $this
        ->t('Internal namespace for this entity and its fields.'),
      '#machine_name' => [
        'exists' => [
          $this,
          'namespaceExists',
        ],
        'label' => $this
          ->t('Namespace'),
      ],
    ];
  }
  else {
    $form['namespace'] = [
      '#type' => 'value',
      '#value' => $namespace,
    ];
  }
  $form['configuration'] = [
    '#type' => 'container',
    '#parents' => [
      'configuration',
    ],
    '#tree' => TRUE,
  ];
  $form['configuration'] += $form_entity
    ->configurationForm($form['configuration'], $form_state);
  $form['actions'] = [
    '#type' => 'actions',
    'submit' => [
      '#type' => 'submit',
      '#value' => $this
        ->t('Save Configuration'),
      '#validate' => [
        [
          $this,
          'validateForm',
        ],
      ],
      '#submit' => [
        [
          $this,
          'submitForm',
        ],
      ],
    ],
    '#ajax' => [
      'callback' => [
        $this,
        'ajaxSubmit',
      ],
      'event' => 'click',
    ],
  ];
  return $form;
}