You are here

public function DateBase::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 YamlFormElementBase::form

3 calls to DateBase::form()
Date::form in src/Plugin/YamlFormElement/Date.php
Gets the actual configuration form array to be built.
DateList::form in src/Plugin/YamlFormElement/DateList.php
Gets the actual configuration form array to be built.
DateTime::form in src/Plugin/YamlFormElement/DateTime.php
Gets the actual configuration form array to be built.
3 methods override DateBase::form()
Date::form in src/Plugin/YamlFormElement/Date.php
Gets the actual configuration form array to be built.
DateList::form in src/Plugin/YamlFormElement/DateList.php
Gets the actual configuration form array to be built.
DateTime::form in src/Plugin/YamlFormElement/DateTime.php
Gets the actual configuration form array to be built.

File

src/Plugin/YamlFormElement/DateBase.php, line 124

Class

DateBase
Provides a base 'date' class.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // Append supported date input format to #default_value description.
  $form['element']['default_value']['#description'] .= '<br />' . $this
    ->t('Accepts any date in any <a href="https://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#Date-input-formats">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.');

  // Allow custom date formats to be entered.
  $form['display']['format']['#type'] = 'yamlform_select_other';
  $form['display']['format']['#other__option_label'] = $this
    ->t('Custom date format...');
  $form['display']['format']['#other__description'] = $this
    ->t('A user-defined date format. See the <a href="http://php.net/manual/function.date.php">PHP manual</a> for available options.');
  $form['date'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Date settings'),
  ];
  $form['date']['min'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Min'),
    '#description' => $this
      ->t('Specifies the minimum date.') . '<br />' . $this
      ->t('Accepts any date in any <a href="https://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#Date-input-formats">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
    '#weight' => 10,
  ];
  $form['date']['max'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Max'),
    '#description' => $this
      ->t('Specifies the maximum date.') . '<br />' . $this
      ->t('Accepts any date in any <a href="https://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#Date-input-formats">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
    '#weight' => 10,
  ];
  return $form;
}