public static function RenderHelper::rewriteStatesSelector in Helper 7
Rewrite #states selectors.
Parameters
array $elements: A renderable array element having a #states property.
string $search: A partial or entire jQuery selector string to replace in #states.
string $replace: The string to replace all instances of $search with.
1 call to RenderHelper::rewriteStatesSelector()
- helper_form_views_ui_config_item_form_alter in ./
helper.module - Implements hook_form_FORM_ID_alter().
File
- lib/
RenderHelper.php, line 15
Class
Code
public static function rewriteStatesSelector(array &$elements, $search, $replace) {
if (!empty($elements['#states'])) {
foreach ($elements['#states'] as $state => $ids) {
foreach ($ids as $id => $value) {
if (strpos($id, $search) !== FALSE) {
$new_id = str_replace($search, $replace, $id);
$elements['#states'][$state][$new_id] = $value;
unset($elements['#states'][$state][$id]);
}
}
}
}
foreach (element_children($elements) as $key) {
static::rewriteStatesSelector($elements[$key], $search, $replace);
}
}