Time-related fields do not show their default values

Created on 4 October 2023, about 1 year ago
Updated 27 July 2024, 4 months ago

Problem/Motivation

The InputDemo form contains default values for 2 date related elements:


    // Date.
    $form['expiration'] = [
      '#type' => 'date',
      '#title' => $this->t('Content expiration'),
      '#default_value' => ['year' => 2020, 'month' => 2, 'day' => 15],
      '#description' => 'Date, #type = date',
    ];

    // Date-time.
    $form['datetime'] = [
      '#type' => 'datetime',
      '#title' => 'Date Time',
      '#date_increment' => 1,
      '#date_timezone' => date_default_timezone_get(),
      '#default_value' => date_default_timezone_get(),
      '#description' => $this->t('Date time, #type = datetime'),
    ];

However, these are not displayed.

Steps to reproduce

1. Enable Form Examples
2. View /examples/form-api-example/input-demo
3. Confirm default value for "Content expiration"
4. Confirm default value for "Date Time"

🐛 Bug report
Status

Fixed

Version

4.0

Component

Form API Example

Created by

🇯🇵Japan tyler36 Osaka

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024