You are here

public function OembedProvidersSettingsForm::buildForm in oEmbed Providers 2.x

Same name and namespace in other branches
  1. 1.0.x src/Form/OembedProvidersSettingsForm.php \Drupal\oembed_providers\Form\OembedProvidersSettingsForm::buildForm()
  2. 1.1.x src/Form/OembedProvidersSettingsForm.php \Drupal\oembed_providers\Form\OembedProvidersSettingsForm::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/OembedProvidersSettingsForm.php, line 73

Class

OembedProvidersSettingsForm
Configure oEmbed settings form.

Namespace

Drupal\oembed_providers\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config(static::SETTINGS);
  $form['external_fetch'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable external fetch of providers'),
    '#description' => $this
      ->t('If enabled, oEmbed providers will be fetched from the <em>oEmbed Providers URL</em>. If disabled, any oEmbed providers must be defined locally.'),
    '#default_value' => $config
      ->get('external_fetch'),
  ];
  $form['oembed_providers_url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('oEmbed Providers URL'),
    '#description' => $this
      ->t('The URL where Media fetches the list of oEmbed providers'),
    '#default_value' => $this
      ->config('media.settings')
      ->get('oembed_providers_url'),
    '#states' => [
      'visible' => [
        ':input[name="external_fetch"]' => [
          'checked' => TRUE,
        ],
      ],
      'required' => [
        ':input[name="external_fetch"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}