You are here

public function YamlFormElementBase::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 YamlFormElementInterface::getConfigurationFormProperties

5 calls to YamlFormElementBase::getConfigurationFormProperties()
DateBase::validateConfigurationForm in src/Plugin/YamlFormElement/DateBase.php
Form validation handler.
DateTime::getConfigurationFormProperties in src/Plugin/YamlFormElement/DateTime.php
Get an associative array of element properties from configuration form.
TextBase::validateConfigurationForm in src/Plugin/YamlFormElement/TextBase.php
Form validation handler.
YamlFormCompositeBase::getConfigurationFormProperties in src/Plugin/YamlFormElement/YamlFormCompositeBase.php
Get an associative array of element properties from configuration form.
YamlFormElementBase::validateConfigurationForm in src/YamlFormElementBase.php
Form validation handler.
2 methods override YamlFormElementBase::getConfigurationFormProperties()
DateTime::getConfigurationFormProperties in src/Plugin/YamlFormElement/DateTime.php
Get an associative array of element properties from configuration form.
YamlFormCompositeBase::getConfigurationFormProperties in src/Plugin/YamlFormElement/YamlFormCompositeBase.php
Get an associative array of element properties from configuration form.

File

src/YamlFormElementBase.php, line 1423

Class

YamlFormElementBase
Provides a base class for a form element.

Namespace

Drupal\yamlform

Code

public function getConfigurationFormProperties(array &$form, FormStateInterface $form_state) {
  $element_properties = $form_state
    ->getValues();

  // Get default properties so that they can be unset below.
  $default_properties = $form_state
    ->get('default_properties');

  // Get custom properties.
  if (isset($element_properties['custom'])) {
    if (is_array($element_properties['custom'])) {
      $element_properties += $element_properties['custom'];
    }
    unset($element_properties['custom']);
  }

  // Remove all hash prefixes so that we can filter out any default
  // properties.
  YamlFormArrayHelper::removePrefix($element_properties);

  // Build a temp element used to see if multiple value and/or composite
  // elements need to be supported.
  $element = YamlFormArrayHelper::addPrefix($element_properties);
  foreach ($element_properties as $property_name => $property_value) {
    if (!isset($default_properties[$property_name])) {
      continue;
    }
    $this
      ->getConfigurationFormProperty($element_properties, $property_name, $property_value, $element);

    // Unset element property that matched the default property.
    if ($default_properties[$property_name] == $element_properties[$property_name]) {
      unset($element_properties[$property_name]);
    }
  }

  // Make sure #type is always first.
  if (isset($element_properties['type'])) {
    $element_properties = [
      'type' => $element_properties['type'],
    ] + $element_properties;
  }
  return YamlFormArrayHelper::addPrefix($element_properties);
}