You are here

public function HidePreviewConfigForm::buildForm in Hide Preview Button 8

Builds and returns the configuration form.

Overrides ConfigFormBase::buildForm

File

src/Form/HidePreviewConfigForm.php, line 29

Class

HidePreviewConfigForm
This class renders and manages the configuration form of the module.

Namespace

Drupal\hide_preview\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $config = $this
    ->config('hide_preview.settings');
  $formNames = $config
    ->get('hide_preview.form_names');
  if (empty($formNames)) {
    $formnames = '';
  }
  else {
    $formNames = implode(PHP_EOL, $formNames);
  }
  $form['form_names'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Form names'),
    '#default_value' => $formNames,
    '#description' => $this
      ->t("<ul><li>Write only one form name per line</li>\n        <li>Do not use comma as a separator</li>\n        <li>Use either a form name as a string or a regular expression.<ul>\n        <li>Check if the <i>form_id</i> begins with the pattern \n        <i>contact_message_</i></li>\n        <li>Check if the <i>form_id</i> matches the regexp \n        <i>/contact_message_*/</i></li>\n        </ul></ul>"),
    '#required' => FALSE,
  ];
  return $form;
}