public ImageToolkitForm::buildForm(array $form, FormStateInterface $form_state)
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 66
Class
- ImageToolkitForm
- Configures image toolkit settings for this site.
Namespace
Drupal\system\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function buildForm( array $form , FormStateInterface $form_state ) { $current_toolkit = $this ->config( 'system.image' )->get( 'toolkit' ); $form [ 'image_toolkit' ] = array ( '#type' => 'radios' , '#title' => $this ->t( 'Select an image processing toolkit' ), '#default_value' => $current_toolkit , '#options' => array (), ); // 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 ] = array ( '#type' => 'details' , '#title' => $this ->t( '@toolkit settings' , array ( '@toolkit' => $definition [ 'title' ])), '#open' => TRUE, '#tree' => TRUE, '#states' => array ( 'visible' => array ( ':radio[name="image_toolkit"]' => array ( 'value' => $id ), ), ), ); $form [ 'image_toolkit_settings' ][ $id ] += $toolkit ->buildConfigurationForm( array (), $form_state ); } return parent::buildForm( $form , $form_state ); } |
Please login to continue.