public function ImageToolkitForm::buildForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/src/Form/ImageToolkitForm.php \Drupal\system\Form\ImageToolkitForm::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
- core/
modules/ system/ src/ Form/ ImageToolkitForm.php, line 68
Class
- ImageToolkitForm
- Configures image toolkit settings for this site.
Namespace
Drupal\system\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$current_toolkit = $this
->config('system.image')
->get('toolkit');
$form['image_toolkit'] = [
'#type' => 'radios',
'#title' => $this
->t('Select an image processing toolkit'),
'#default_value' => $current_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);
}