You are here

public function CustomForm::validateForm in Facebook Comments Box 8

Youtube API credentials form validate.

Overrides FormBase::validateForm

File

src/Form/CustomForm.php, line 138

Class

CustomForm
Configure custom settings for this site.

Namespace

Drupal\facebook_comments_box\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $admin_id = $form_state
    ->getValue('facebook_comments_box_admin_id');
  $default_comments = $form_state
    ->getValue('facebook_comments_box_default_comments');
  $default_width = $form_state
    ->getValue('facebook_comments_box_default_width');
  $default_theme = $form_state
    ->getValue('facebook_comments_box_default_theme');
  $node_types = $form_state
    ->getValue('facebook_comments_box_default_node_types');
  if (isset($admin_id) && isset($default_comments) && isset($default_width) && isset($default_theme) && isset($node_types)) {
    $this
      ->configFactory()
      ->getEditable('facebook_comments_box.settings')
      ->set('facebook_comments_box_admin_id', $admin_id)
      ->save();
    $this
      ->configFactory()
      ->getEditable('facebook_comments_box.settings')
      ->set('facebook_comments_box_default_comments', $default_comments)
      ->save();
    $this
      ->configFactory()
      ->getEditable('facebook_comments_box.settings')
      ->set('facebook_comments_box_default_width', $default_width)
      ->save();
    $this
      ->configFactory()
      ->getEditable('facebook_comments_box.settings')
      ->set('facebook_comments_box_default_theme', $default_theme)
      ->save();
    $this
      ->configFactory()
      ->getEditable('facebook_comments_box.settings')
      ->set('facebook_comments_box_node_types', $node_types)
      ->save();
    drupal_set_message(t('Facebook comments box credentials saved successfully'));
  }
}