You are here

public static function OfficeHoursDatelist::validateOfficeHoursSlot in Office Hours 8

Validate the hours selector element.

Parameters

$element:

\Drupal\Core\Form\FormStateInterface $form_state:

$complete_form:

File

src/Element/OfficeHoursDatelist.php, line 114

Class

OfficeHoursDatelist
Provides a one-line text field form element.

Namespace

Drupal\office_hours\Element

Code

public static function validateOfficeHoursSlot(&$element, FormStateInterface $form_state, &$complete_form) {
  $input = $element['#value'];
  $value = '';
  if (isset($input['object']) && $input['object']) {
    $value = (string) $input['object']
      ->format('Gi');

    // Set the value for usage in OfficeHoursList::validateOfficeHoursSlot().
    $element['#value'] = $value;
  }
  $form_state
    ->setValueForElement($element, $value);
}