You are here

public function DateList::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/DateList.php, line 44

Class

DateList
Provides a 'datelist' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function setDefaultValue(array &$element) {
  if (!empty($element['#default_value']) && is_string($element['#default_value'])) {
    $element['#default_value'] = $element['#default_value'] ? DrupalDateTime::createFromTimestamp(strtotime($element['#default_value'])) : NULL;
  }
}