You are here

public function PageSpecificClassSettingsForm::buildForm in Page Specific Class 8

Same name and namespace in other branches
  1. 2.0.x src/Form/PageSpecificClassSettingsForm.php \Drupal\page_specific_class\Form\PageSpecificClassSettingsForm::buildForm()

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/PageSpecificClassSettingsForm.php, line 30

Class

PageSpecificClassSettingsForm
Configure custom settings for Page Specific Class.

Namespace

Drupal\page_specific_class\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('page_specific_class.settings');
  $description = $this
    ->t('Mention path of pages where you want to add class in body tag.');
  $description .= '<ul>';
  $description .= '<li>' . $this
    ->t('An example <b>path is /hello-world</b> and you want to <b>add class "xyz"</b> on body tag of this page then enter  <b>/hello-world|xyz</b> in text-area') . '</li>';
  $description .= '<li>' . $this
    ->t('An example <b>path is /page-example</b> and you want to <b>add multiple classes like "xyz1 xyz2 xyz3"</b> on body tag of this page then enter  <b>/hello-world|xyz1 xyz2 xyz3</b> in text-area') . '</li>';
  $description .= '<li>' . $this
    ->t('If you want to <b>add class "home-page"</b> in <b>home page</b> body tag then enter  <b>/&lt;front&gt;|home-page</b>') . '</li>';
  $description .= '<li>' . $this
    ->t('To <b>add class "all-page"</b> in <b>each page</b> body tag then enter <b>/*|all-page</b>') . '</li>';
  $description .= '<li>' . $this
    ->t('Enter <b>one path</b> along with class <b>per line</b>') . '</li>';
  $description .= '<li>' . $this
    ->t('Path should <b>start with "/"</b> as well as path and class should <b>seperated with "|".</b>') . '</li>';
  $description .= '</ul>';
  $form['url_with_class'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Enter url along with class "|" seperated and path should start with "/"'),
    '#description' => $description,
    '#rows' => 10,
    '#default_value' => $config
      ->get('url_with_class'),
  ];
  return parent::buildForm($form, $form_state);
}