You are here

public function ResponsiveWrappersSettings::buildForm in Responsive wrappers 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/ResponsiveWrappersSettings.php \Drupal\responsivewrappers\Form\ResponsiveWrappersSettings::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/ResponsiveWrappersSettings.php, line 30

Class

ResponsiveWrappersSettings
Configure Responsive wrappers settings.

Namespace

Drupal\responsivewrappers\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('responsivewrappers.settings');
  $form['version'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Bootstrap output version'),
    '#options' => [
      3 => $this
        ->t('Bootstrap 3'),
      4 => $this
        ->t('Bootstrap 4'),
      5 => $this
        ->t('Bootstrap 5'),
      0 => $this
        ->t('Custom'),
    ],
    '#default_value' => $config
      ->get('version'),
    '#description' => $this
      ->t('The HTML output for responsive images or tables has changed between Bootstrap 3 and Bootstrap 4/5. You can choose witch output version you want, for example bootstrap 3 uses img-responsive class and bootstrap 4/5 img-fluid.'),
  ];
  $form['add_css'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Attach responsive wrappers CSS'),
    '#options' => [
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes'),
    ],
    '#default_value' => $config
      ->get('add_css'),
    '#description' => $this
      ->t('If you are using a Bootstrap 3/4/5 theme or subtheme the responsive classes works without any extra CSS, if not you can use this to add the CSS styles needed to work.'),
  ];

  // Custom classes.
  $form['custom_classes'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Custom classes'),
    '#description' => $this
      ->t('Custom responsive classes. Choose "Custom" in bootstrap output version to change this custom classes.'),
  ];
  $form['custom_classes']['image_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Custom image class'),
    '#default_value' => $config
      ->get('image_class'),
  ];
  $form['custom_classes']['iframe_wrapper_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Custom iframe wrapper class'),
    '#default_value' => $config
      ->get('iframe_wrapper_class'),
  ];
  $form['custom_classes']['iframe_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Custom iframe class'),
    '#default_value' => $config
      ->get('iframe_class'),
  ];
  $form['custom_classes']['table_wrapper_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Custom table wrapper class'),
    '#default_value' => $config
      ->get('table_wrapper_class'),
  ];
  $form['custom_classes']['table_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Custom table class'),
    '#default_value' => $config
      ->get('table_class'),
  ];
  return parent::buildForm($form, $form_state);
}