public function WebformTime::prepare in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformTime.php \Drupal\webform\Plugin\WebformElement\WebformTime::prepare()
Prepare an element to be rendered within a webform.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.
Overrides WebformElementBase::prepare
See also
\Drupal\webform\Element\WebformCompositeBase::processWebformComposite
File
- src/
Plugin/ WebformElement/ WebformTime.php, line 43
Class
- WebformTime
- Provides a 'webform_time' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
// Set default time format to HTML time.
if (!isset($element['#time_format'])) {
$element['#time_format'] = $this
->getDefaultProperty('time_format');
}
// Set placeholder attribute.
if (!empty($element['#placeholder'])) {
$element['#attributes']['placeholder'] = $element['#placeholder'];
}
// Prepare element after date format has been updated.
parent::prepare($element, $webform_submission);
}