ImageToolkitForm::buildForm

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

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);
}
doc_Drupal
2016-10-29 09:20:08
Comments
Leave a Comment

Please login to continue.