You are here

function _length_indicator_settings_optimax in Length Indicator 8

Validate optimax value.

Parameters

array $element: Form element to be validated.

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

1 string reference to '_length_indicator_settings_optimax'
length_indicator_field_widget_third_party_settings_form in ./length_indicator.module
Implements hook_field_widget_third_party_settings_form().

File

./length_indicator.module, line 106
Length Indicator module hooks.

Code

function _length_indicator_settings_optimax(array $element, FormStateInterface &$form_state) {
  $parents = array_slice($element['#parents'], 0, -1);
  $indicator_opt = $form_state
    ->getValue($parents);
  if ($indicator_opt['optimax'] <= $indicator_opt['optimin']) {
    $form_state
      ->setError($element, t('Optimum maximum has to be greater than the optimum minimum'));
  }
}