You are here

public function DateTime::getDefaultProperties in YAML Form 8

Only a few elements don't inherit these default properties.

Overrides DateBase::getDefaultProperties

See also

\Drupal\yamlform\Plugin\YamlFormElement\Textarea

\Drupal\yamlform\Plugin\YamlFormElement\YamlFormLikert

\Drupal\yamlform\Plugin\YamlFormElement\YamlFormCompositeBase

\Drupal\yamlform\Plugin\YamlFormElement\ContainerBase

File

src/Plugin/YamlFormElement/DateTime.php, line 25

Class

DateTime
Provides a 'datetime' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function getDefaultProperties() {
  $date_format = '';
  $time_format = '';

  // Date formats cannot be loaded during install or update.
  if (!defined('MAINTENANCE_MODE')) {

    /** @var \Drupal\Core\Datetime\DateFormatInterface $date_format_entity */
    if ($date_format_entity = DateFormat::load('html_date')) {
      $date_format = $date_format_entity
        ->getPattern();
    }

    /** @var \Drupal\Core\Datetime\DateFormatInterface $time_format_entity */
    if ($time_format_entity = DateFormat::load('html_time')) {
      $time_format = $time_format_entity
        ->getPattern();
    }
  }
  return parent::getDefaultProperties() + [
    // Date settings.
    'date_date_format' => $date_format,
    'date_date_element' => 'date',
    'date_time_format' => $time_format,
    'date_time_element' => 'time',
    'date_year_range' => '1900:2050',
    'date_increment' => 1,
    'date_timezone' => '',
  ];
}