You are here

public function EntityReferenceLayoutSettingsForm::buildForm in Entity Reference with Layout 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 ConfigFormBase::buildForm

File

src/Form/EntityReferenceLayoutSettingsForm.php, line 68

Class

EntityReferenceLayoutSettingsForm
Class EntityReferenceLayoutSettingsForm.

Namespace

Drupal\entity_reference_layout\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->configFactory()
    ->getEditable('entity_reference_layout.settings');
  $erl_config_schema = $this->typedConfigManager
    ->getDefinition('entity_reference_layout.settings') + [
    'mapping' => [],
  ];
  $erl_config_schema = $erl_config_schema['mapping'];
  $form['show_paragraph_labels'] = [
    '#type' => 'checkbox',
    '#title' => $erl_config_schema['show_paragraph_labels']['label'],
    '#description' => $erl_config_schema['show_paragraph_labels']['description'],
    '#default_value' => $config
      ->get('show_paragraph_labels'),
  ];
  $form['show_layout_labels'] = [
    '#type' => 'checkbox',
    '#title' => $erl_config_schema['show_layout_labels']['label'],
    '#description' => $erl_config_schema['show_layout_labels']['description'],
    '#default_value' => $config
      ->get('show_layout_labels'),
  ];
  return parent::buildForm($form, $form_state);
}