function string_fields_form($form, $pid) {
// somewhere about here I ought to force this form to actually destroy any previous ideas it had of itself and start over
$result =
db_query("select slid, name, max_chars, platform FROM {fr_scrn_locations} JOIN {fr_platform} using (pid) where pid = %d",
$pid);
$j = '0';
'#type' => 'textfield',
'#size' => '15',
'#value' => $scrn_locs['name'],
'#prefix' => '<tr><td class="location-field">',
);
$form['slid'.
$j] =
array (
'#type' => 'hidden',
'#value' => $scrn_locs['slid'],
'#suffix' => '</td>',
);
$form['max_chars'.
$j] =
array(
'#type' => 'textfield',
'#size' => '4',
'#value' => $scrn_locs['max_chars'],
'event' => 'blur',
'path' => 'ahah/strings/platform/'.$j,
'wrapper' => 'form-wrapper',
),
'#prefix' => '<td class="maxchars-field">',
'#suffix' => '</td></tr>',
);
if ($j == 0 ) {
$platform = $scrn_locs['platform'];
}
$j++;
}
$form['loc0']['#prefix'] = '<table><tr> <th>field name</th><th>max chars</th></tr><tr><td class="location-field">';
'#type' => 'textfield',
'#size' => '15',
'#prefix' => '<tr><td class="location-field">',
'#suffix' => '</td>',
);
$form['newmax_chars'] =
array(
'#type' => 'textfield',
'#size' => '4',
'#value' => $scrn_locs['max_chars'],
'event' => 'blur',
'path' => 'ahah/strings/newplatform/'.$pid,
'wrapper' => 'form-wrapper',
),
'#prefix' => '<td class="maxchars-field">',
'#suffix' => '</td></tr>',
);
$form['#prefix'] = '<h2>'.$platform.' Fields</h2>';
$form['#suffix'] = '</table>';
return $form;
}
/*
* insert the new form field into the db and then give me the form again
*/
function fr_newplatform_ahah($pid) {
$cache =
cache_get('form_'.
$_POST['form_build_id'],
'cache_form');
$form_state =
array('values' =>
$_POST);
// put newloc and newmax_chars into the db
$sql = "INSERT INTO {fr_scrn_locations} SET name = '%s', max_chars = %d, pid= %d";
db_query($sql,
$form_state['values']['newloc'],
$form_state['values']['newmax_chars'],
$pid);
// give me the form again -- but fresh.
// This should replace everything inside form-wrapper.
// what's happening though is that I'm not getting the new info, so clearly I'm not really re-doing the form. :(
}