You are here

public function AutofloatSettingsForm::buildForm in AutoFloat 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/AutofloatSettingsForm.php, line 30

Class

AutofloatSettingsForm
Class AutofloatSettingsForm.

Namespace

Drupal\autofloat\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->get('autofloat.settings');
  $form['autofloat_start'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Start with the first image on the..'),
    '#options' => [
      0 => $this
        ->t('right'),
      1 => $this
        ->t('left (swaps "odd" and "even" classes)'),
    ],
    '#default_value' => $config
      ->get('start'),
    '#description' => $this
      ->t('Clear the site cache to apply changes.'),
  ];
  $form['autofloat_css'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use autofloat.css'),
    '#default_value' => $config
      ->get('css'),
    '#description' => $this
      ->t('Uncheck to take care of the floating and margins yourself in custom css.'),
  ];
  $form['target_settings'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Selector/rejector settings'),
    '#description' => $this
      ->t('Images will float unless they have the class "nofloat". Clear the site cache to apply changes. Avoid adding classes manually by defining classes here added by other modules/filters. Use your browser inspector to find them.'),
  ];
  $form['target_settings']['autofloat_target'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Elements to target'),
    '#options' => [
      'div' => $this
        ->t('div'),
      'span' => $this
        ->t('span'),
    ],
    '#default_value' => $config
      ->get('target'),
    '#description' => $this
      ->t('Clear the site cache to apply changes.'),
  ];
  $form['target_settings']['autofloat_selector'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Additional selector classes to float'),
    '#default_value' => $config
      ->get('selector'),
    '#description' => $this
      ->t('A "selector" with the class "float" will float all containing content, e.g. the image with a caption under it. Optionally define others. Maximum two, divided by a comma. Example: "caption".'),
  ];
  $form['target_settings']['autofloat_rejector'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Additional div classes to ignore'),
    '#default_value' => $config
      ->get('rejector'),
    '#description' => $this
      ->t('Images nested within any element with the class "nofloat" will NOT float, e.g. a set of thumbnails. Optionally define others. Maximum two, divided by a comma. Example: "flickr-photoset".'),
  ];
  return parent::buildForm($form, $form_state);
}