You are here

public function AjaxConfigForm::buildForm in Ajax Add to Cart 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/AjaxConfigForm.php, line 65

Class

AjaxConfigForm
Class AjaxConfigForm.

Namespace

Drupal\ajax_add_to_cart\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('ajax_add_to_cart.ajaxconfig');
  $form['ajax_modal_settings'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Modal window settings'),
    '#description' => $this
      ->t('Modal window settings'),
  ];
  $form['ajax_modal_settings']['time_ajax_modal'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Enter time after which modal window closes.'),
    '#default_value' => $config
      ->get('time_ajax_modal'),
    '#description' => $this
      ->t('Enter time in miliseconds like: 2000 stands for 2 seconds'),
  ];
  $form['ajax_modal_settings']['ajax_modal_width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Please choose width of modal window.'),
    '#default_value' => $config
      ->get('ajax_modal_width'),
    '#size' => self::AJAX_MODAL_INPUT_SIZE,
    '#field_suffix' => ' px',
  ];
  $form['ajax_modal_settings']['ajax_modal_height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Please choose height of modal window.'),
    '#default_value' => $config
      ->get('ajax_modal_height'),
    '#size' => self::AJAX_MODAL_INPUT_SIZE,
    '#field_suffix' => ' px',
  ];
  return parent::buildForm($form, $form_state);
}