You are here

function _length_indicator_settings_tolerance in Length Indicator 8

Validate tolerance 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_tolerance'
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 123
Length Indicator module hooks.

Code

function _length_indicator_settings_tolerance(array $element, FormStateInterface &$form_state) {
  $parents = array_slice($element['#parents'], 0, -1);
  $indicator_opt = $form_state
    ->getValue($parents);
  if ($indicator_opt['tolerance'] >= $indicator_opt['optimin']) {
    $form_state
      ->setError($element, t('Tolerance has to be smaller than the optimum minimum'));
  }
}