You are here

public function DateTime::getConfigurationFormProperties in YAML Form 8

Get an associative array of element properties from configuration form.

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 of element properties.

Overrides YamlFormElementBase::getConfigurationFormProperties

File

src/Plugin/YamlFormElement/DateTime.php, line 240

Class

DateTime
Provides a 'datetime' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

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

  // Remove hidden date properties.
  if (isset($properties['#date_date_element'])) {
    switch ($properties['#date_date_element']) {
      case 'datetime':
      case 'datetime-local':
        unset($properties['#date_time_element'], $properties['#date_time_format'], $properties['#date_increment']);
        break;
      case 'none':
        unset($properties['#date_date_format'], $properties['#date_year_range']);
        break;
    }
  }

  // Remove hidden date properties.
  if (isset($properties['#date_time_element']) && $properties['#date_time_element'] == 'none') {
    unset($properties['#date_time_format'], $properties['date_increment']);
  }
  return $properties;
}