You are here

public function DateTime::getConfigurationFormProperties in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/DateTime.php \Drupal\webform\Plugin\WebformElement\DateTime::getConfigurationFormProperties()

Get an associative array of element properties from configuration webform.

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 WebformElementBase::getConfigurationFormProperties

File

src/Plugin/WebformElement/DateTime.php, line 376

Class

DateTime
Provides a 'datetime' element.

Namespace

Drupal\webform\Plugin\WebformElement

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 'date':
        unset($properties['#date_date_format']);
        break;
      case 'datetime':
      case 'datetime-local':
        unset($properties['#date_date_format'], $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'])) {
    switch ($properties['#date_time_element']) {
      case 'time':
        unset($properties['#date_time_format']);
        break;
      case 'none':
        unset($properties['#date_time_format'], $properties['date_increment']);
        break;
    }
  }
  return $properties;
}