protected function WebformSubmissionForm::setFormPropertiesFromElements in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::setFormPropertiesFromElements()
Set the webform properties from the elements.
Parameters
array $form: An associative array containing the structure of the form.
array $elements: An associative array containing the elements.
1 call to WebformSubmissionForm::setFormPropertiesFromElements()
- WebformSubmissionForm::form in src/
WebformSubmissionForm.php - Gets the actual form array to be built.
File
- src/
WebformSubmissionForm.php, line 2153
Class
- WebformSubmissionForm
- Provides a webform to collect and edit submissions.
Namespace
Drupal\webformCode
protected function setFormPropertiesFromElements(array &$form, array &$elements) {
foreach ($elements as $key => $value) {
if (is_string($key) && $key[0] === '#') {
$value = $this->tokenManager
->replace($value, $this
->getEntity(), [], [], $this->bubbleableMetadata);
if (isset($form[$key]) && is_array($form[$key]) && is_array($value)) {
$form[$key] = NestedArray::mergeDeep($form[$key], $value);
}
else {
$form[$key] = $value;
}
// Remove the properties from the $elements and $form['elements'] array.
unset($elements[$key], $form['elements'][$key]);
}
}
// Replace token in #attributes.
if (isset($form['#attributes'])) {
$form['#attributes'] = $this->tokenManager
->replace($form['#attributes'], $this
->getEntity(), [], [], $this->bubbleableMetadata);
}
}