Verified Commit 4f46b8b9 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #2836530 by shalini_jha, rishabh vishwakarma, pontus_nilsson, mpdonadio,...

Issue #2836530 by shalini_jha, rishabh vishwakarma, pontus_nilsson, mpdonadio, Nikhil_110, eojthebrave, ravi.shankar: Update Date element documentation for #date_date_format and usage for other date types such as time
parent 5acde36f
Loading
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -6,17 +6,30 @@
use Drupal\Core\Render\Element;

/**
 * Provides a form element for date selection.
 * Provides a form element for date or time selection.
 *
 * Properties:
 * - #default_value: A string for the default date in 'Y-m-d' format.
 * - #attributes: An associative array containing:
 *   - type: The type of date field rendered, valid values include 'date',
 *     'time', 'datetime', and 'datetime-local'.
 * - #date_date_format: The date format used in PHP formats.
 * - #default_value: A string representing the date formatted as Y-m-d, or
 *   hh:mm for time.
 * - #size: The size of the input element in characters.
 *
 * @code
 * $form['expiration'] = [
 *   '#type' => 'date',
 *   '#title' => $this->t('Content expiration'),
 *   '#default_value' => '2020-02-05',
 *   '#date_date_format' => 'Y-m-d',
 *   '#default_value' => '2020-02-15',
 *   '#size' => 10,
 * ];
 *
 * $form['game_time'] = [
 *   '#type' => 'date',
 *   '#title' => $this->t('The game is at'),
 *   '#attributes' => ['type' => 'time'],
 * ];
 * @endcode
 */