function ImageToolkitForm::buildForm

Same name in other branches
  1. 9 core/modules/system/src/Form/ImageToolkitForm.php \Drupal\system\Form\ImageToolkitForm::buildForm()
  2. 8.9.x core/modules/system/src/Form/ImageToolkitForm.php \Drupal\system\Form\ImageToolkitForm::buildForm()
  3. 11.x core/modules/system/src/Form/ImageToolkitForm.php \Drupal\system\Form\ImageToolkitForm::buildForm()

Overrides ConfigFormBase::buildForm

File

core/modules/system/src/Form/ImageToolkitForm.php, line 72

Class

ImageToolkitForm
Configures image toolkit settings for this site.

Namespace

Drupal\system\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['image_toolkit'] = [
        '#type' => 'radios',
        '#title' => $this->t('Select an image processing toolkit'),
        '#config_target' => 'system.image:toolkit',
        '#options' => [],
    ];
    // If we have more than one image toolkit, allow the user to select the one
    // to use, and load each of the toolkits' settings form.
    foreach ($this->availableToolkits as $id => $toolkit) {
        $definition = $toolkit->getPluginDefinition();
        $form['image_toolkit']['#options'][$id] = $definition['title'];
        $form['image_toolkit_settings'][$id] = [
            '#type' => 'details',
            '#title' => $this->t('@toolkit settings', [
                '@toolkit' => $definition['title'],
            ]),
            '#open' => TRUE,
            '#tree' => TRUE,
            '#states' => [
                'visible' => [
                    ':radio[name="image_toolkit"]' => [
                        'value' => $id,
                    ],
                ],
            ],
        ];
        $form['image_toolkit_settings'][$id] += $toolkit->buildConfigurationForm([], $form_state);
    }
    return parent::buildForm($form, $form_state);
}

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