SettingsForm.php

Same filename in this branch
  1. 11.x core/modules/navigation/src/Form/SettingsForm.php
Same filename in other branches
  1. 9 core/modules/media_library/src/Form/SettingsForm.php
  2. 9 core/modules/aggregator/src/Form/SettingsForm.php
  3. 8.9.x core/modules/media_library/src/Form/SettingsForm.php
  4. 8.9.x core/modules/aggregator/src/Form/SettingsForm.php
  5. 10 core/modules/media_library/src/Form/SettingsForm.php
  6. 10 core/modules/navigation/src/Form/SettingsForm.php

Namespace

Drupal\media_library\Form

File

core/modules/media_library/src/Form/SettingsForm.php

View source
<?php

namespace Drupal\media_library\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Defines a form for configuring the Media Library module.
 *
 * @internal
 *   Form classes are internal.
 */
class SettingsForm extends ConfigFormBase {
    
    /**
     * {@inheritdoc}
     */
    public function getEditableConfigNames() {
        return [
            'media_library.settings',
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'media_library_settings_form';
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state) {
        $form['advanced_ui'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Enable advanced UI'),
            '#default_value' => $this->config('media_library.settings')
                ->get('advanced_ui'),
            '#description' => $this->t('If checked, users creating new media items in the media library will see a summary of their selected media items, and they will be able to insert their selection directly into the media field or text editor.'),
        ];
        return parent::buildForm($form, $form_state);
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        $this->config('media_library.settings')
            ->set('advanced_ui', (bool) $form_state->getValue('advanced_ui'))
            ->save();
        parent::submitForm($form, $form_state);
    }

}

Classes

Title Deprecated Summary
SettingsForm Defines a form for configuring the Media Library module.

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