You are here

function _yamlform_form_after_build in YAML Form 8

Alter form after build.

1 string reference to '_yamlform_form_after_build'
yamlform_form_alter in ./yamlform.module
Implements hook_form_alter().

File

./yamlform.module, line 152
Enables the creation of forms and questionnaires.

Code

function _yamlform_form_after_build($form, FormStateInterface $form_state) {
  $form_object = $form_state
    ->getFormObject();

  // Add contextual links and change theme wrapper to yamlform.html.twig
  // which includes 'title_prefix' and 'title_suffix' variables needed for
  // contextual links to appear.
  $form['#contextual_links']['yamlform'] = [
    'route_parameters' => [
      'yamlform' => $form_object
        ->getEntity()
        ->getYamlForm()
        ->id(),
    ],
  ];
  $form['#theme_wrappers'] = [
    'yamlform',
  ];
  return $form;
}