checkboxes on custom node types

kyle_mathews - September 20, 2007 - 19:34

I'm creating a custom content type but not with CCK as I need the extra flexability.
I'm using Pro Drupal Development and everything was going smoothly until I tried adding checkboxes to my node creation form in hook_form. I can't seem to figure out how to save them to the database nor how to retrieve those values from $node so I can add them back to the node form when editing my content. As an added complication (I'm guessing), the checkbox elements are inside a fieldset.

This is my code from hook_insert and hook_form:
hook_form

// fieldset for options if students are reviewing content
  $form['review'] = array(
    '#type' => 'fieldset',
    '#title' => t('Reviewing options'),
    '#collapsible' => FALSE
  );
   $form['review']['review_options'] = array(
    '#title' => t("Review options"),
    '#type' => 'checkboxes',
    '#default_value' => variable_get('review_options', 0),
    '#description' => (t('Check the options which apply')),
    '#options' => array(
      'students_comment' => t("Students must leave students_comments?"),
      'rate' => t("Students must rate writing?"),
      'inline' => t('Students review using inline students_comments? (Inline students_comments are better for longer pieces)')
    )
  );

hook_insert
/**
* Implementation of hook_insert().
*/
function writing_assignment_insert($node) {
  db_query("INSERT INTO {writing_assignment} (nid, vid, in_class, start_date, end_date, students_review, num_reviews, students_comment, rate, inline) VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
    $node->nid, $node->vid, $node->in_class, $node->start_time, $node->end_time, $node->students_review, $node->num_reviews, $node->students_comment, $node->rate, $node->inline);
  drupal_set_message('<pre>'.$node->review.'</pre>');
}

Any help is greatly appreciated.

solved?

lunatix - November 20, 2007 - 07:06

Hi! I am having the same problem currently, have you figured out how to do it?

thanks

 
 

Drupal is a registered trademark of Dries Buytaert.