public function JsonApiImageStylesAdminForm::buildForm in JSON:API Image Styles 8
Same name and namespace in other branches
- 2.0.x src/Form/JsonApiImageStylesAdminForm.php \Drupal\jsonapi_image_styles\Form\JsonApiImageStylesAdminForm::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/ JsonApiImageStylesAdminForm.php, line 33
Class
- JsonApiImageStylesAdminForm
- Class JsonApiImageStylesAdminForm.
Namespace
Drupal\jsonapi_image_styles\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('jsonapi_image_styles.settings');
$options = [];
$styles = ImageStyle::loadMultiple();
foreach ($styles as $name => $style) {
$options[$name] = $style
->label();
}
$form['image_styles'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Image styles'),
'#description' => $this
->t('Select image styles to expose for JSON:API. If none are selected, all styles are exposed.'),
'#options' => $options,
'#default_value' => is_array($config
->get('image_styles')) ? $config
->get('image_styles') : [],
];
return parent::buildForm($form, $form_state);
}