You are here

public function ClientsideValidationjQuerySettingsForm::buildForm in Clientside Validation 8

Same name and namespace in other branches
  1. 8.2 clientside_validation_jquery/src/Form/ClientsideValidationjQuerySettingsForm.php \Drupal\clientside_validation_jquery\Form\ClientsideValidationjQuerySettingsForm::buildForm()
  2. 3.0.x clientside_validation_jquery/src/Form/ClientsideValidationjQuerySettingsForm.php \Drupal\clientside_validation_jquery\Form\ClientsideValidationjQuerySettingsForm::buildForm()
  3. 2.0.x clientside_validation_jquery/src/Form/ClientsideValidationjQuerySettingsForm.php \Drupal\clientside_validation_jquery\Form\ClientsideValidationjQuerySettingsForm::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

clientside_validation_jquery/src/Form/ClientsideValidationjQuerySettingsForm.php, line 30

Class

ClientsideValidationjQuerySettingsForm
Class ClientsideValidationjQuerySettingsForm.

Namespace

Drupal\clientside_validation_jquery\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $config = $this
    ->config('clientside_validation_jquery.settings');
  $form['use_cdn'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use JS from CDN'),
    '#description' => $this
      ->t('CDN is used by default if JS not added into libraries.'),
    '#default_value' => $config
      ->get('use_cdn'),
  ];
  $form['cdn_base_url'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('CDN Base URL'),
    '#description' => $this
      ->t('CDN to use (along with version in URL). E.g. @url', [
      '@url' => '//cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/',
    ]),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('cdn_base_url'),
  ];
  $form['validate_all_ajax_forms'] = [
    '#type' => 'select',
    '#options' => [
      1 => $this
        ->t('Yes'),
      2 => $this
        ->t('No'),
    ],
    '#title' => $this
      ->t('Validate all forms before AJAX submit'),
    '#description' => $this
      ->t('All forms with class "cv-validate-before-ajax" will be validated by default'),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('validate_all_ajax_forms'),
  ];
  $form['force_validate_on_blur'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Validate on Blur/focusout'),
    '#default_value' => $config
      ->get('force_validate_on_blur'),
  ];
  return $form;
}