You are here

public function AjaxLinksApiSettingsForm::buildForm in Ajaxify Drupal with JQuery Ajax 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/AjaxLinksApiSettingsForm.php, line 23

Class

AjaxLinksApiSettingsForm
Displays the Ajax links API settings form.

Namespace

Drupal\ajax_links_api\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = \Drupal::config('ajax_links_api.admin_settings');
  $form['ajax_links_api_trigger'] = array(
    '#type' => 'textarea',
    '#title' => t('jQuery selector to trigger ajax (One per line)'),
    '#default_value' => $config
      ->get('ajax_links_api.trigger'),
    '#description' => t('Just like jQuery, for example by providing ".content a" will ajaxify all link under .content. You can also exclude some selectors by specifying ! (for example "!#toolbar a")'),
  );
  $form['ajax_links_api_selector'] = array(
    '#type' => 'textfield',
    '#title' => t('Default Target DIV'),
    '#default_value' => $config
      ->get('ajax_links_api.selector'),
    '#description' => t('This can be override for indivdual link by providing rel. Check Demo.'),
  );
  $form['ajax_links_api_html5'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable URL and Title change (for HTML5 Only)'),
    '#default_value' => $config
      ->get('ajax_links_api.html5'),
    '#description' => t('Change URL and Title according to ajax content. This will work only for HTML5 supported browsers. Tested on latest Chrome,Firefox.'),
  );
  $form['ajax_links_api_scripts_included'] = array(
    '#type' => 'checkbox',
    '#title' => t('Included js-bottom-placeholder in template'),
    '#default_value' => $config
      ->get('ajax_links_api.scripts_included'),
    '#description' => t('If you removed js-bottom-placeholder from html--ajax.html.twig, uncheck this. For details, please check https://drupal.org/node/1923320'),
  );
  $form['ajax_links_api_vpager'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove ?ajax=1 from Views pager'),
    '#default_value' => $config
      ->get('ajax_links_api.vpager'),
    '#description' => t('Remove ?ajax=1 from Views pager. For details, please check http://drupal.org/node/1907376.'),
  );
  return parent::buildForm($form, $form_state);
}