I'm creating this form with checkboxes that I want to populate from a database. The problem is, how do I create an array of key=>value pairs when the data I need to create the pairs is in an object? I'm not sure I'm explaining myself properly, heres' the code and hopefully it will be clearer:
function myform_form($form, &$form_state) {
$options_query = db_query('SELECT name, mname FROM event_type');
$options = array();
foreach($options_query as $o) {
$options(($o->mname) => ($o->name)); //This is where I get the error unexpected T_DOUBLE_ARROW
}
$form['options'] = array(
'#type' => 'checkboxes',
'#title' => t('Search options'),
'#options' => $options,
'#description' => t('Choose what you want.'),
);
Is there a way to do this?