You are here

public function CustomTipsEditForm::validateForm in BeautyTips 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormInterface::validateForm

File

beautytips_manager/src/Form/CustomTipsEditForm.php, line 211

Class

CustomTipsEditForm

Namespace

Drupal\beautytips_manager\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $tip = $form_state
    ->getValue('tip');
  $positions = $tip['position'];
  foreach ($positions as $position => $order) {
    if ($order !== '' && !is_numeric($order)) {
      $form_state
        ->setErrorByName("tip][positions][{$position}", t('You must enter a numeric value for position order (Or leave it blank).'));
    }
  }
}