123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- function ctools_dependent_process($element, &$form_state, &$form) {
- return $element;
- }
- function ctools_dependent_pre_render($element) {
-
- 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'],
- );
-
- if (in_array($element['#type'], array('textarea', 'fieldset', 'text_format'))) {
- $element['#theme_wrappers'][] = 'container';
- $element['#attributes']['id'] = $element['#id'] . '-wrapper';
- }
-
-
- 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;
- }
- function ctools_dependent_element_info_alter(&$type) {
- $form_elements = array('checkbox', 'checkboxes', 'date', 'fieldset', 'item', 'machine_name', 'markup', 'radio', 'radios', 'select', 'textarea', 'textfield', 'text_format');
- foreach ($form_elements as $element) {
- $type[$element]['#pre_render'][] = 'ctools_dependent_pre_render';
- }
- }
|