public function Webform::setElementProperties in Webform 8.5
Same name and namespace in other branches
- 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::setElementProperties()
Set element properties.
Parameters
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
$this
Overrides WebformInterface::setElementProperties
File
- src/
Entity/ Webform.php, line 1858
Class
- Webform
- Defines the webform entity.
Namespace
Drupal\webform\EntityCode
public function setElementProperties($key, array $properties, $parent_key = '') {
$elements = $this
->getElementsDecoded();
// If element is was not added to elements, add it as the last element.
if (!$this
->setElementPropertiesRecursive($elements, $key, $properties, $parent_key)) {
if ($this
->hasActions() && array_key_exists(end($this->elementsActions), $elements)) {
// Add element before the last 'webform_actions' element if action is
// not placed into container.
$last_action_key = end($this->elementsActions);
$updated_elements = [];
foreach ($elements as $element_key => $element) {
if ($element_key === $last_action_key) {
$updated_elements[$key] = $properties;
}
$updated_elements[$element_key] = $element;
}
$elements = $updated_elements;
}
else {
$elements[$key] = $properties;
}
}
$this
->setElements($elements);
return $this;
}