You are here

public function DateBase::validateConfigurationForm in YAML Form 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides YamlFormElementBase::validateConfigurationForm

1 call to DateBase::validateConfigurationForm()
DateList::validateConfigurationForm in src/Plugin/YamlFormElement/DateList.php
Form validation handler.
1 method overrides DateBase::validateConfigurationForm()
DateList::validateConfigurationForm in src/Plugin/YamlFormElement/DateList.php
Form validation handler.

File

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

Class

DateBase
Provides a base 'date' class.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $properties = $this
    ->getConfigurationFormProperties($form, $form_state);

  // Validate #default_value GNU Date Input Format.
  if ($properties['#default_value'] && strtotime($properties['#default_value']) === FALSE) {
    $this
      ->setInputFormatError($form['properties']['element']['default_value'], $form_state);
  }

  // Validate #min and #max GNU Date Input Format.
  $input_formats = [
    'min',
    'max',
  ];
  foreach ($input_formats as $input_format) {
    if (!empty($properties["#{$input_format}"]) && strtotime($properties["#{$input_format}"]) === FALSE) {
      $this
        ->setInputFormatError($form['properties']['date'][$input_format], $form_state);
    }
  }
  parent::validateConfigurationForm($form, $form_state);
}