Hi,
I've got a form_pre_render() function created which reads a database table to determine whether a checkbox is supposed to be checked or not (this works fine). The form is then supposed to update the table on submit (have a gform_after_submission() function for that).
Something odd is going on though. Every 10 days (the check boxes are one per day of the month), it seems either my code, php or the gforms code seems to "skip" an id so although the form displays properly (all days are there), the $entry traversal code gets messed up. The "mess-up" increments by 1 every 10 days so:
<li class='gchoice_2_9'><input name='input_2.9' type='checkbox' value='9' id='choice_2_9' tabindex='10' /><label for='choice_2_9'>Jan 9</label><li class='gchoice_2_11'><input name='input_2.11' type='checkbox' value='10' id='choice_2_11' tabindex='11' /><label for='choice_2_11'>Jan 10</label>
The same thing happens on the 20th (ID skips 2_21) and the 30th.
My code for creating the $choices and $inputs (apologies for the cut/paste as well as _ugly_ code:
[SNIP]
for ($i = 0; $i < $numDaysInMonth ; $i++)
{
$cnt = $i + 1;
$sqlStr = "SELECT boolDay" . $cnt . " FROM ChallengeTracker WHERE ((strName='" . $strName . "') AND (numMonth=" . $numMonth . "));";
$dbResult = $wpdb->get_var( $wpdb->prepare( $sqlStr ) );
fprintf($fh, "SQL: " . $sqlStr . "\n");
if ($dbResult != NULL) {
fprintf($fh, "Result returned: " . $dbResult . "\n");
}
// We've located the day where
if ($cnt == $numDay)
{
$strDayInfo = "" . $arrMonth[$numMonthIndex] . " " . $cnt . "";
} else {
$strDayInfo = $arrMonth[$numMonthIndex] . " " . $cnt;
}
if ($dbResult != NULL)
{
$choices[] = array("text" => $strDayInfo, "value" => $cnt, "isSelected" => "1");
} else {
$choices[] = array("text" => $strDayInfo, "value" => $cnt);
}
$inputs[] = array("label" => $arrMonth[$numMonthIndex] . " " . $cnt, "id" => $numFieldID . "." . $i);
} // End of For Loop
//Adding items to field id $numFieldID
foreach($form["fields"] as &$field) {
if($field["id"] == $numFieldID) {
$field["choices"] = $choices;
$field["inputs"] = $inputs;
}
[SNIP]