Sunday, 25 August 2013
Adding values to checkboxes from db table
Adding values to checkboxes from db table References I am quite new to drupal 7. I need to add names which come from db table into checkboxes. How do i do that? I have written my callback form function below: function page_second_callback_form($form){ $result = db_query(\'SELECT n.names FROM {my_test_tab} n\'); $output =\'\'; foreach($result as $item) { $output .= $item->names; } $opt = array($output => $output,); $form[\'check\'] = array( \'#type\' => \'fieldset\', \'#title\' => \'some\', \'#collapsible\' => TRUE, \'#collapsed\' => TRUE, ); $form[\'check\'][\'chk_box\'] = array( \'#type\' => \'checkboxes\', \'#title\' => \'check box title go here.\', \'#required\' => TRUE, \'#descrfiption\' => \'some descriptions for checkboxes.\', \'#options\' => $opt, ); $form[\'check\'][\'submit\'] = array( \'#type\' => \'submit\', \'#value\' => \'Delete\', ); return $form; }
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment