// The story so far...
function fringslate_menu() {
/*
* Lots of irrelevant menu entries
* ...and then:
*/
$items['strings/%/%'] =
array( // the two wildcards let me say which field and node I'm talking about
'title' => 'administer fring strings',
'page callback' => "fr_strings_admin_ajax",
'page arguments' =>
array(1,
2),
'access arguments' =>
array('create strings'),
);
}
function fr_strings_admin_form($form_id, $strings) {
foreach($strings as $string){
if(!
empty($string['nid'])) {
$form['str_key'.
$string['nid']] =
array(
'#type' => 'textfield',
'#size' => '20',
'#default_value' => $string['str_key'],
'event' => 'change',
'path' => 'strings/str_key/'.$string['nid'],
)
);
/*
* some other form fields
* ...
*/
}
return $form;
}
function fr_strings_admin_ajax($field, $nid){
$cache =
cache_get('form_'.
$_POST['form_build_id'],
'cache_form');
$form = $cache->data;
$form_state =
array('values' =>
$_POST);
// update the db for JUST ONE ITEM
// on second thought this should be a module_invoke and I should use node to do the updatery here.
// this will do for now, though
db_query('UPDATE {fr_strings} set '.
$field.
' = "'.
$form_state['values'][$field.
$nid].
'" WHERE tnid = '.
$nid);
}