Skip to main content
Cleaning up title. I have also added javascript as a tag because perhaps someone with javascript can solve this alternatively.
Source Link

I have a form element that I would like initially to have selected/checked Checkbox Form Element: Displaying checkboxes for. However, the element already has a default value based on on/off

I have a checkbox form element with checkboxes that uses taxonomy terms via variable_getvariable_get as default for the form element and stores#default_value; storing the result. I don't want to overwrite the stored value so, I just want the form to render/display checked initially.

  $form['search_block_topic'] = array(
    '#type' => 'checkboxes',
    '#options' => $topic_options,
    '#default_value' => variable_get('search_topic_options', $topic_options)

I tried '#return_value' => "checked", which doesn't work.

I have a form element that I would like initially to have selected/checked checkboxes for. However, the element already has a default value

I have a form element with checkboxes that uses taxonomy terms via variable_get as default for the form element and stores the result. I don't want to overwrite the stored value so I just want the form to render checked initially.

  $form['search_block_topic'] = array(
    '#type' => 'checkboxes',
    '#options' => $topic_options,
    '#default_value' => variable_get('search_topic_options', $topic_options)

I tried '#return_value' => "checked", which doesn't work.

Checkbox Form Element: Displaying checkboxes value based on on/off

I have a checkbox form element that uses taxonomy terms via variable_get as #default_value; storing the result. I don't want to overwrite value, I just want the form to render/display checked initially.

  $form['search_block_topic'] = array(
    '#type' => 'checkboxes',
    '#options' => $topic_options,
    '#default_value' => variable_get('search_topic_options', $topic_options)

I tried '#return_value' => "checked" which doesn't work.

Source Link

I have a form element that I would like initially to have selected/checked checkboxes for. However, the element already has a default value

I have a form element with checkboxes that uses taxonomy terms via variable_get as default for the form element and stores the result. I don't want to overwrite the stored value so I just want the form to render checked initially.

  $form['search_block_topic'] = array(
    '#type' => 'checkboxes',
    '#options' => $topic_options,
    '#default_value' => variable_get('search_topic_options', $topic_options)

I tried '#return_value' => "checked", which doesn't work.