function tabledrag_example_simple_form_submit
Submit callback for the tabledrag_example_simple_form form.
Updates the 'weight' column for each element in our table, taking into account that item's new order after the drag and drop actions have been performed.
Related topics
File
-
tabledrag_example/
tabledrag_example_simple_form.inc, line 168
Code
function tabledrag_example_simple_form_submit($form, &$form_state) {
// Because the form elements were keyed with the item ids from the database,
// we can simply iterate through the submitted values.
foreach ($form_state['values']['example_items'] as $id => $item) {
db_query("UPDATE {tabledrag_example} SET weight = :weight WHERE id = :id", array(
':weight' => $item['weight'],
':id' => $id,
));
}
}