function ctools_dependent_pre_render
1 string reference to 'ctools_dependent_pre_render'
- ctools_dependent_element_info_alter in includes/
dependent.inc - CTools alters the element_info to be able to add #process functions to every major form element to make it much more handy to use #dependency, because you don't have to add #process.
File
-
includes/
dependent.inc, line 137
Code
function ctools_dependent_pre_render($element) {
// Preprocess only items with #dependency set.
if (isset($element['#dependency'])) {
if (!isset($element['#dependency_count'])) {
$element['#dependency_count'] = 1;
}
if (!isset($element['#dependency_type'])) {
$element['#dependency_type'] = 'hide';
}
$js = array(
'values' => $element['#dependency'],
'num' => $element['#dependency_count'],
'type' => $element['#dependency_type'],
);
// Add a additional wrapper id around fieldsets, textareas to support depedency on it.
if (in_array($element['#type'], array(
'textarea',
'fieldset',
'text_format',
))) {
$element['#theme_wrappers'][] = 'container';
$element['#attributes']['id'] = $element['#id'] . '-wrapper';
}
// Text formats need to unset the dependency on the textarea
// or it gets applied twice.
if ($element['#type'] == 'text_format') {
unset($element['value']['#dependency']);
}
$element['#attached']['js'][] = ctools_attach_js('dependent');
$options['CTools']['dependent'][$element['#id']] = $js;
$element['#attached']['js'][] = array(
'type' => 'setting',
'data' => $options,
);
}
return $element;
}