Drupal: how to make crashes with CTools

I use Ctools Dependency to make a set of fields hidden. This is part of my code:

$form['profile-status'] = array(
    '#type' => 'radios',
    '#title' => '',
    '#options' => array(
        'new' => t('Create a new profile.'),
        'select' => t('Use an existing profile.'),
    ),
);

$form['select'] = array(
    '#type' => 'select',
    '#title' => t('Select a profile'),
    '#options' => $options,
    '#process' => array('ctools_dependent_process'),
    '#dependency' => array('radio:profile-status' => array('select')),
);

$form['profile-properties'] = array(
    '#type' => 'fieldset',
    '#title' => t('View the profile'),
    '#process' => array('ctools_dependent_process'),
    '#dependency' => array('radio:profile-status' => array('select')),
    '#input' => true,
);

In the snippet above, there are two elements, one selection and one set of fields. Both have #process and #dependency parameters and both point to the same field for the dependent value. The problem is that elements such as select or a text field can be easily hidden, but this does not work for a set of fields. In this support request page , the creator of CTools noted that '#input' => true- this is work. As you can see, I added it to the code, but it does not work.

Do you have any suggestions?

+5
source share
2 answers

CTools. Fieldset :

$form['profile-properties'] = array(
    '#type' => 'fieldset',
    '#title' => t('View the profile'),
    '#process' => array('ctools_dependent_process'),
    '#dependency' => array('radio:profile-status' => array('select')),
    '#input' => true,

    '#id' => 'my-fs-id',
    '#prefix' => '<div id="my-fs-id-wrapper">',
    '#suffix' => '</div>',
);

. DIV. DIV feildset '-wrapper'.

+5

( 2013) :

$form['foo_or_bar'] = array(
    '#title' => 'Foo or Bar',
    '#type' => 'radios',
    '#options' => array(
        "foo" => "Foo",
        "bar" => "Bar"
    ),
    '#default_value' => "foo",
);

$form['react_on_foo'] = array(
    '#type' => 'fieldset',
    '#title' => t('Foo fieldset'),
    '#dependency' => array('radio:foo_or_bar' => array('foo')),
);

$form['react_on_foo']['dummy_for_foo_fieldset'] = array(
    '#title' => t('Dummy for FOO fieldset'),
    '#type' => 'textfield',
);


$form['react_on_bar'] = array(
    '#type' => 'fieldset',
    '#title' => t('Bar fieldset'),
    '#dependency' => array('radio:foo_or_bar' => array('bar')),
);

$form['react_on_bar']['dummy_for_bar_fieldset'] = array(
    '#title' => t('Dummy for BAR fieldset'),
    '#type' => 'textfield',
);

#process .

+1

All Articles