I have two problems, one of which is relevant minor, and one of which is critical to my module working.
I have defined a new node type, called a 'Jeopardy Game' which allows users to submit questions and then from those questions create a game of Jeopardy (themed with CSS and using Javascript to hide/unhide the questions). I've got most of the code working, but I'm having trouble with the actual saving of the information.
I've created a table in the database, and it is mostly being updated correctly except for the question/category fields. Since the number of fields is set in a settings callback, I need to be able to adjust what is inserted into the database each time. Can anyone help me with the proper syntax for this?
Also the minor problem is that the form fields aren't being presented in the order I've created them, so I need to figure out how to fix that as well.
Here is my relevant code so far:
<?php
/**
* Implementation of hook_form().
*/
function jeopardy_form(&$node) {
$rows = variable_get('number_of_questions', 5);
$cols = variable_get('number_of_categories', 5);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Name of game - should be unique!'),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5);
$n = 0;
for ($j=1;$j<=$rows;$j++) {
$n++;
$form['category'][$j] = array(