function WebformCalculationComponentsFormTree::insertNewAttribute in Webform Calculation Components 7
Same name and namespace in other branches
- 7.2 WebformCalculationComponentsFormTree.php \WebformCalculationComponentsFormTree::insertNewAttribute()
Inserts new attributes in the argument array.
Parameters
array $form_submitted_array: The submitted array where the components are stored.
array $tree_path: The list of components forming a tree path to select the form element where we need to insert the new attribute. The list contains form keys.
array $new_attributes: An associative array to insert in the specified tree path.
Return value
bool It returns true if the new attributes have been inserted and false if not.
File
- ./
WebformCalculationComponentsFormTree.php, line 66 - Handles the arrays passed in the webform node.
Class
- WebformCalculationComponentsFormTree
- @file Handles the arrays passed in the webform node.
Code
function insertNewAttribute(array &$form_submitted_array, array $tree_path, array $new_attributes) {
$aux =& $form_submitted_array;
foreach ($tree_path as $key) {
if (isset($aux[$key])) {
$aux =& $aux[$key];
}
else {
return FALSE;
}
}
if (is_array($aux) && isset($new_attributes)) {
foreach ($new_attributes as $new_attribute_key => $new_attribute_value) {
$aux[$new_attribute_key] = $new_attribute_value;
}
}
return TRUE;
}