Show Related Record Lists after Edit Record?
Posted: Wed Feb 24, 2010 3:20 pm
I have two tables in my application. The project_mstr table is a parent table, and project_agreements is a child table that has a foreign key column "pa_project_id" that links back to the project_mstr table.
I set up the relationships.ini for project_mstr as follows:
So far so good. I see an "agreements" tab for a given project_mstr record. I can add new agreements records, and once I edit the new agreements record and save I return to the list of related agreements records.
My question is on editing an existing agreement record. It is not quite the same as adding a new agreement record. The user is taken out of the project / agreement relationship. Once the record is edited and saved, the page redirects back to the editing the same record.
What I would like to accomplish is as follows:
1) Hook into the event under the "Save" button, so that after the record is updated, the page redirects back to the list of related agreements records, that are related from the project_mstr record. e.g. same behavior as "add new"
2) Add a "Cancel" button that performs no database updates, but redirects back to the list of related agreements records.
For 1) my thought was to implement the "after_action_edit()" function in the Application Delegate class (since I would like this behavior consistent across all relationships). My hunch is to set up a link with the action=related_records_list, based on the code from new_related_record.php. However when I tried this I get errors since the relationship is lost when editing the existing record.
For 2) I was also thinking of implementing a block__blockname() function in the Application Delegate class for the cancel button. Is it available on that class? The button would use the related_records_list action as well, to return to the list.
Am I on the right track?
I set up the relationships.ini for project_mstr as follows:
- Code: Select all
[Agreements]
project_agreements.pa_project_id = "$pm_project_id"
So far so good. I see an "agreements" tab for a given project_mstr record. I can add new agreements records, and once I edit the new agreements record and save I return to the list of related agreements records.
My question is on editing an existing agreement record. It is not quite the same as adding a new agreement record. The user is taken out of the project / agreement relationship. Once the record is edited and saved, the page redirects back to the editing the same record.
What I would like to accomplish is as follows:
1) Hook into the event under the "Save" button, so that after the record is updated, the page redirects back to the list of related agreements records, that are related from the project_mstr record. e.g. same behavior as "add new"
2) Add a "Cancel" button that performs no database updates, but redirects back to the list of related agreements records.
For 1) my thought was to implement the "after_action_edit()" function in the Application Delegate class (since I would like this behavior consistent across all relationships). My hunch is to set up a link with the action=related_records_list, based on the code from new_related_record.php. However when I tried this I get errors since the relationship is lost when editing the existing record.
For 2) I was also thinking of implementing a block__blockname() function in the Application Delegate class for the cancel button. Is it available on that class? The button would use the related_records_list action as well, to return to the list.
Am I on the right track?