By fiasst-1 on
I've spent the best part of a week on and off Google searching for an answer to this, and no suggestions have worked.
HOW do you check specific checkboxes using default_values? Example:
<?php
$list_options = array(11 => "List One", 15 => "List Two", 22 => "List Three");
$form['build_lists'] = array(
'#type' => 'checkboxes',
'#title' => t('Choose a List(s)'),
'#options' => $list_options,
'#description' => t("Select a List"),
'#required' => TRUE,//if I didnt need at lease 1 of these boxes to be required Id simple create them 1 by 1 with '#type' => 'checkbox' but, I do..
'#weight' => 1,
'#default_value' => array(11, 15, 22),//I can't find any way of ordering these with any method of array_keys/array_values...
);
?>
Any help is very much appreciated!
Comments
I don't see anything wrong
I don't see anything wrong with your code.
Did you tried the example:
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
Is it working?
Hi, thanks for trying
but sadly, no. The example didn't work for me. Anything else I can try?
Apparently all you need is an array of your options key_values but ive tried every variant of that I can think of...
I desperately need this to work..
Are you using a clean
Are you using a clean installation of Drupal?
Maybe you have some custom modules that interacts with your form.
Ionut
I'm using my own custom
I'm using my own custom module but literally the code in my example is what I've got in my form. The only thing to note is that it's the second step of a multipart form. But I've been using print_r($form_values) to confirm the form is working as expected.
I'm completely stumped...
I think the #default_value
I think the #default_value should be before the #options in your form element definition. That is
Ive tried that and sorry to
Ive tried that and sorry to say it didnt work either. Thanks for trying though.
Any more suggestions?