public function Date::form in YAML Form 8
Gets the actual configuration form array to be built.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An associative array contain the element's configuration form without any default values..
Overrides DateBase::form
File
- src/
Plugin/ YamlFormElement/ Date.php, line 59
Class
- Date
- Provides a 'date' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$date_format = DateFormat::load('html_date')
->getPattern();
$form['date']['date_date_format'] = [
'#type' => 'yamlform_select_other',
'#title' => $this
->t('Date format'),
'#options' => [
$date_format => $this
->t('Year-Month-Date (@date)', [
'@date' => date($date_format),
]),
],
'#description' => $this
->t("Date format is only applicable for browsers that do not have support for the HTML5 date element. Browsers that support the HTML5 date element will display the date using the user's preferred format."),
'#other__option_label' => $this
->t('Custom...'),
'#other__placeholder' => $this
->t('Custom date format...'),
'#other__description' => $this
->t('Enter date format using <a href="http://php.net/manual/en/function.date.php">Date Input Format</a>.'),
];
$form['date']['step'] = [
'#type' => 'number',
'#title' => $this
->t('Step'),
'#description' => $this
->t('Specifies the legal number intervals.'),
'#min' => 1,
'#size' => 4,
'#weight' => 10,
];
return $form;
}