You are here

public function ParserConfigurationForm::buildForm in Markdown 8.2

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 FormInterface::buildForm

File

src/Form/ParserConfigurationForm.php, line 124

Class

ParserConfigurationForm
Form for modifying parser configuration.

Namespace

Drupal\markdown\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ParserInterface $parser = NULL) {

  // Set the parser.
  $this
    ->setParser($parser);
  $form += [
    '#parents' => [],
    '#title' => $this
      ->t('Configure @parser', [
      '@parser' => $parser
        ->getLabel(FALSE),
    ]),
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save configuration'),
    '#button_type' => 'primary',
  ];

  // By default, render the form using system-config-form.html.twig.
  $form['#theme'] = 'system_config_form';

  // Due to the way the Form API works, any time a property is explicitly
  // specified, the default property values are not included. It must be
  // manually retrieved and set here.
  $form['#process'] = $this->elementInfo
    ->getInfoProperty('form', '#process', []);

  // Build the subform via a #process callback.
  $form['#process'][] = [
    $this,
    'processSubform',
  ];
  return $form;
}