You are here

protected function YamlForm::setElementPropertiesRecursive in YAML Form 8

Set element properties.

Parameters

array $elements: An associative nested array of elements.

string $key: The element's key.

array $properties: An associative array of properties.

string $parent_key: (optional) The element's parent key. Only used for new elements.

Return value

bool TRUE when the element's properties has been set. FALSE when the element has not been found.

1 call to YamlForm::setElementPropertiesRecursive()
YamlForm::setElementProperties in src/Entity/YamlForm.php
Set element properties.

File

src/Entity/YamlForm.php, line 969

Class

YamlForm
Defines the form entity.

Namespace

Drupal\yamlform\Entity

Code

protected function setElementPropertiesRecursive(array &$elements, $key, array $properties, $parent_key = '') {
  foreach ($elements as $element_key => &$element) {
    if (Element::property($element_key) || !is_array($element)) {
      continue;
    }
    if ($element_key == $key) {
      $element = $properties + YamlFormElementHelper::removeProperties($element);
      return TRUE;
    }
    if ($element_key == $parent_key) {
      $element[$key] = $properties;
      return TRUE;
    }
    if ($this
      ->setElementPropertiesRecursive($element, $key, $properties, $parent_key)) {
      return TRUE;
    }
  }
  return FALSE;
}