public static function OfficeHoursDatetime::valueCallback in Office Hours 8
Callback for office_hours_select element.
Takes #default_value and dissects it in hours, minutes and ampm indicator. Mimics the date_parse() function.
- g = 12-hour format of an hour without leading zeros 1 through 12
- G = 24-hour format of an hour without leading zeros 0 through 23
- h = 12-hour format of an hour with leading zeros 01 through 12
- H = 24-hour format of an hour with leading zeros 00 through 23
Parameters
array $element:
mixed $input:
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
array|mixed|null The value, as entered by the user.
Overrides Datetime::valueCallback
File
- src/
Element/ OfficeHoursDatetime.php, line 57
Class
- OfficeHoursDatetime
- Provides a one-line HTML5 time element.
Namespace
Drupal\office_hours\ElementCode
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
$input['time'] = OfficeHoursDatetime::get($element['#default_value'], 'H:i');
$input = parent::valueCallback($element, $input, $form_state);
$element['#default_value'] = $input;
return $input;
}