You are here

public function DurationWidget::settingsFormValidate in Duration Field 8

Validate the submitted settings.

File

src/Plugin/Field/FieldWidget/DurationWidget.php, line 99

Class

DurationWidget
Creates a default widget to output a duration field.

Namespace

Drupal\duration_field\Plugin\Field\FieldWidget

Code

public function settingsFormValidate($element, FormStateInterface $form_state) {
  $duration = $form_state
    ->getValue($element['#parents']);
  if ($error_message = $this->durationService
    ->checkDurationInvalid($this->durationService
    ->convertValue($duration))) {
    $form_state
      ->setError($element, $error_message);
  }
}