By mpapet on
I'm a newbie that is taking a crack at his first module.
I need to fire off a function that inserts some data from a customized form into a table.
I've got the form built. What isn't clear to me is how to fire off a function to save a fivestar rating with the 'preview' or 'save' buttons. I have a feeling I don't have the 'rateit' portion of the form stored in a variable for my rating either. See below for my simple form.
function review_content_type_form(&$node) {
$type = node_get_types('type', $node);
// We need to define form elements for the node's title and body.
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5
);
$form['body'] = array (
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#required' => TRUE
);
$form['rateit'] = array (
'#title' => t('Rate this thing!'),
'#type' => 'fivestar',
'#stars' => 5,
);
$form ['body_filter']['filter'] = filter_form($node->format);
return $form;
}
Any help would be great.
Comments
No Preview Functions
More info:
Steps to reproduce the problem.
I've got a new content type that adds a fivestar widget to the bottom of a story so the author can write a review. My clever module works up until preview.
1. I see the new content type inside the site menu, I can click on it and it renders my nice new form with the fivestar widget on the bottom.
2. I enter a title, some text in the body and click 5/5 stars.
3. Clicking on preview, the 5/5 stars is not rendered in the preview and my best guess at passing the score stored in the 'new' review to the 'preview' is adding a variable declaration to the item. But this variable is null if I attempt to write a custom preview.
It looks like one way to do this is with hook_nodeapi and use the validate function to store the value. Dunno if node_form_build_preview has any capabilities as it is not documented in an example.