public function DateTime::setDefaultValue in YAML Form 8
Set an element's default value using saved data.
Parameters
array $element: An element.
Overrides YamlFormElementBase::setDefaultValue
File
- src/
Plugin/ YamlFormElement/ DateTime.php, line 73
Class
- DateTime
- Provides a 'datetime' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function setDefaultValue(array &$element) {
if (is_string($element['#default_value']) && !empty($element['#default_value'])) {
$element['#default_value'] = $element['#default_value'] ? DrupalDateTime::createFromTimestamp(strtotime($element['#default_value'])) : NULL;
}
}