function Alignment::buildConfigurationForm

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::buildConfigurationForm()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::buildConfigurationForm()

Form for choosing which alignment types are available.

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php, line 51

Class

Alignment
CKEditor 5 Alignment plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['enabled_alignments'] = [
        '#type' => 'fieldset',
        '#title' => $this->t('Enabled Alignments'),
        '#description' => $this->t('These are the alignment types that will appear in the alignment dropdown.'),
    ];
    foreach ($this->getPluginDefinition()
        ->getCKEditor5Config()['alignment']['options'] as $alignment_option) {
        $name = $alignment_option['name'];
        $form['enabled_alignments'][$name] = [
            '#type' => 'checkbox',
            '#title' => $this->t($name),
            '#return_value' => $name,
            '#default_value' => in_array($name, $this->configuration['enabled_alignments'], TRUE) ? $name : NULL,
        ];
    }
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.