public static function DurationElement::validateElement in Duration Field 3.0.x
Same name and namespace in other branches
- 8.2 src/Element/DurationElement.php \Drupal\duration_field\Element\DurationElement::validateElement()
Converts the date array to a PHP DateInterval object, and sets the object as the value of the form element. All handlers after this point will receive the PHP DateInterval element as the value for this form element.
File
- src/
Element/ DurationElement.php, line 223
Class
- DurationElement
- Defines the 'duration' form element.
Namespace
Drupal\duration_field\ElementCode
public static function validateElement(&$element, FormStateInterface $form_state, $form) {
$date_array = $form_state
->getValue($element['#parents']);
$form_state
->setValueForElement($element, \Drupal::service('duration_field.service')
->convertDateArrayToDateInterval($date_array));
}