You are here

public function YamlFormCompositeBase::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/YamlFormCompositeBase.php, line 611

Class

YamlFormCompositeBase
Provides a base for composite elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function getConfigurationFormProperties(array &$form, FormStateInterface $form_state) {
  $properties = parent::getConfigurationFormProperties($form, $form_state);
  foreach ($properties as $key => $value) {

    // Convert composite element access and required to boolean value.
    if (strpos($key, '__access') || strpos($key, '__required')) {
      $properties[$key] = (bool) $value;
    }

    // If the entire element is required remove required property for
    // composite elements.
    if (!empty($properties['required']) && strpos($key, '__required')) {
      unset($properties[$key]);
    }
  }
  return $properties;
}