You are here

public function FormEntryTypeBase::validateConfigurationForm in Flag 8.4

Validates the action link setting form.

Derived classes will want to override this method.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Overrides ActionLinkTypeBase::validateConfigurationForm

1 call to FormEntryTypeBase::validateConfigurationForm()
FieldEntry::validateConfigurationForm in src/Plugin/ActionLink/FieldEntry.php
Validates the action link setting form.
1 method overrides FormEntryTypeBase::validateConfigurationForm()
FieldEntry::validateConfigurationForm in src/Plugin/ActionLink/FieldEntry.php
Validates the action link setting form.

File

src/Plugin/ActionLink/FormEntryTypeBase.php, line 106

Class

FormEntryTypeBase
Base class for link types using form entry.

Namespace

Drupal\flag\Plugin\ActionLink

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state
    ->getValues();
  if ($form_values['link_type'] == 'confirm') {
    if (empty($form_values['flag_confirmation'])) {
      $form_state
        ->setErrorByName('flag_confirmation', $this
        ->t('A flag confirmation message is required when using the "@label" link type.', [
        '@label' => $this->pluginDefinition['label'],
      ]));
    }
    if (empty($form_values['unflag_confirmation'])) {
      $form_state
        ->setErrorByName('unflag_confirmation', $this
        ->t('An unflag confirmation message is required when using the "@label" link type.', [
        '@label' => $this->pluginDefinition['label'],
      ]));
    }
  }
}