protected function WebformSubmissionForm::addStatesPrefix in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::addStatesPrefix()
Add unique class prefix to all :input #states selectors.
Parameters
array $array: An associative array.
Return value
array An associative array with unique class prefix added to all :input #states selectors.
1 call to WebformSubmissionForm::addStatesPrefix()
- WebformSubmissionForm::prepareElements in src/
WebformSubmissionForm.php - Prepare webform elements.
File
- src/
WebformSubmissionForm.php, line 2587
Class
- WebformSubmissionForm
- Provides a webform to collect and edit submissions.
Namespace
Drupal\webformCode
protected function addStatesPrefix(array $array) {
$prefixed_array = [];
foreach ($array as $key => $value) {
if (strpos($key, ':input') === 0) {
$key = $this->statesPrefix . ' ' . $key;
$prefixed_array[$key] = $value;
}
elseif (is_array($value)) {
$prefixed_array[$key] = $this
->addStatesPrefix($value);
}
else {
$prefixed_array[$key] = $value;
}
}
return $prefixed_array;
}