Hi-
I'm working on an action to send an email to everyone in a role group (e.g. "Send an email to editors when new content is in the draft state").
I need to set up a check box of roles. Here is the code:
$roles = user_roles();
$form['recipients'] = array(
'#type' => 'checkboxes',
'#title' => t('Recipient Role Groups'),
'#options' => $roles,
'#description' => t('Select which roles should receive this email.'),
);
The creates an #options field with the form:
array( rid1 => 'role name 1', rid2 => 'role name 2' ...)
This works well at first, and I can properly save the form, but if I return to the edit screen later, the form isn't properly populated because I have an $edit array that looks like:
[recipients] => Array ( [3] => 3 [1] => 0 [2] => 0 [4] => 0 [5] => 0 [6] => 0 )
All the other fields (subject, message body, etc) are nicely filled in. I suspect this is because the options I supply in the code, don't match the options in the $edit array.
Any thoughts on how I can get these to mesh?
Thanks
-Mark