By mpruitt on
Prior to working with Drupal, I was able to write php functions that would force a user to confirm before being able to edit/delete any data record they were working with.
I'm trying to do the same within Drupal (version 5), and I found a nice example from Drupal 6 that takes advantage of using a wildcard in the dynamic menu path (http://www.akchauhan.com/create-an-action-confirm-form-using-confirm_for...).
Because you have to address the dynamic path differently in Drupal 5, I'm tripping all over my own feet (http://drupal.org/node/209056).
Does anyone have an example from Drupal 5 similar to the example in the above link? In advance, thanks for helping the "Drubie" (Drupal newbie).
Comments
This May be Useful to Someone Else
I figured out how to do this by reading a lot of posts here on the form. Too many individuals to thank separately, but all of the info I needed was here in the Drupal community.
In the menu hook section:
The code for the "Delete" link at the end of each table row:
In the above snippent, "{$data->ID}" is included in the path that calls the "record_confirm_delete" function, and can be extracted inside the function by using "func_get_arguments". Since the ID number is the first (and only) value appended to the path, it's in position [0].
There's probably a better way to do this (please let me know if there is), but after capturing the ID value, I "store" it in a hidden field so I can retrieve it inside the follow up function, which in my case is "record_confirm_delete_submit".
Once I click the "Delete" button, I get sent to the "record_delete_confirm_submit" function.
I'm an old-school programmer, and I make it a practice to never delete a record from a database, I just mark it as inactive, which is what happens in the following function.
I have another view available only to super admins showing all inactive records. Instead of "Delete", I have "Activate" at the end of each row, so I can re-activate a record if needed.