Populate checkboxes

ru.meta - September 29, 2009 - 12:18
Project:Prepopulate
Version:6.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I've tried to populate user roles from url
/admin/user/user/create?edit[account][roles]=7
and found that #default_value replaced with string. Also I tried to use
edit[account][roles][]=7
with no success.
The solution I found is to replace
$form['#default_value'] = $getslice;
with

if (is_array($form['#default_value'])) {
  $form['#default_value'][] = $getslice;
} else {
  $form['#default_value'] = $getslice;
}

Is there better way?

#1

ru.meta - September 29, 2009 - 12:18
Title:Populace checkboxes» Populate checkboxes

#2

MadOverlord - November 3, 2009 - 16:06

With taxonomy select boxes (not checkboxes), at least, you can do multiple select:

node/add/product?edit[taxonomy][3][]=11&edit[taxonomy][3][]=10

and single select like this:

node/add/product?edit[taxonomy][3]=11

I don't know if this will be helpful for checkboxes though.

 
 

Drupal is a registered trademark of Dries Buytaert.