You are here

EasyMetaConfigurationForm.php in Easymeta 8

File

src/Form/EasyMetaConfigurationForm.php
View source
<?php

namespace Drupal\easymeta\Form;

use Drupal\Core\Form\ConfigFormBase;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormStateInterface;

/**
 * Defines a form that configures forms module settings.
 */
class EasyMetaConfigurationForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'easymeta_admin_settings';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'easymeta.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
    $config = $this
      ->config('easymeta.settings');
    $form['use_og_meta'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Use OG meta'),
      '#default_value' => $config
        ->get('use_og_meta'),
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $values = $form_state
      ->getValues();
    $this
      ->config('easymeta.settings')
      ->set('use_og_meta', $values['use_og_meta'])
      ->save();
  }

}

Classes

Namesort descending Description
EasyMetaConfigurationForm Defines a form that configures forms module settings.