public function DateList::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/ DateList.php, line 77
Class
- DateList
- Provides a 'datelist' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['date'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Date list settings'),
];
$form['date']['date_part_order_label'] = [
'#type' => 'item',
'#title' => $this
->t('Date part and order'),
'#description' => $this
->t("Select the date parts and order that should be used in the element."),
'#access' => TRUE,
];
$form['date']['date_part_order'] = [
'#type' => 'yamlform_tableselect_sort',
'#header' => [
'part' => 'Date part',
],
'#options' => [
'day' => [
'part' => $this
->t('Days'),
],
'month' => [
'part' => $this
->t('Months'),
],
'year' => [
'part' => $this
->t('Years'),
],
'hour' => [
'part' => $this
->t('Hours'),
],
'minute' => [
'part' => $this
->t('Minutes'),
],
'second' => [
'part' => $this
->t('Seconds'),
],
'ampm' => [
'part' => $this
->t('AM/PM'),
],
],
];
$form['date']['date_text_parts'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Date text parts'),
'#description' => $this
->t("Select date parts that should be presented as text fields instead of drop-down selectors."),
'#options' => [
'day' => $this
->t('Days'),
'month' => $this
->t('Months'),
'year' => $this
->t('Years'),
'hour' => $this
->t('Hours'),
'minute' => $this
->t('Minutes'),
'second' => $this
->t('Seconds'),
],
];
$form['date']['date_year_range'] = [
'#type' => 'textfield',
'#title' => $this
->t('Date year range'),
'#description' => $this
->t("A description of the range of years to allow, like '1900:2050', '-3:+3' or '2000:+3', where the first value describes the earliest year and the second the latest year in the range.") . ' ' . $this
->t('Use min/max validation to define a more specific date range.'),
];
$form['date']['date_increment'] = [
'#type' => 'number',
'#title' => $this
->t('Date increment'),
'#description' => $this
->t('The increment to use for minutes and seconds'),
'#min' => 1,
'#size' => 4,
];
return $form;
}