Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By JoeRobertsPhotography on
Can help me save the results of the drupal_add_tabledrag inside of block that would be awesome. I am trying to loop through the results inside of hook_block_save() but that isn't working.
The example that I found uses the form submit button not sure how to do something similar to this inside a block.
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)
);
}
}
Inside the hook_block_save I don't think I have access to the $form_State['values']. Please help.
Thanks,
Joe
Comments
I figured it out with some
I figured it out with some help from Devel module. I printed the $edit varaible and found the values in there so I was able to use this code inside of the MYMODULE_block_save to get the updated tabledrag variables and update the weight module with the correct weights.