⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Losing data when returning from a View action



jgalak1

jgalak1
  • profile picture
  • Member

Posted 25 June 2020 - 18:55 PM

Here's the situation:  I have a table of tags linked to a table of items (many-many relationship).  My application is set up to display the list of tags with GroceryCRUD, and each row gets a custom action button that takes me to a list of items that have that tag. 

 

Clicking the button generates a link in the form ".../index.php/result_c/result_list/cats/3" where 'result_c' is my controller class, 'result_list' is the functions, 'cats' is a command, and '3' in this example is the index value of the tag being searched.  'result_c' compiles these results and generates another GroceryCRUD screen, this time of the items matching the tag.  It allows a single command button - View.

 

Clicking the view button takes me to a URL in this form: ".../index.php/result_c/result_list/cats/3/read/6362" (where '6362' is the index number of the item clicked on).  The user can then click the "Back to List" button which takes them back to ".../index.php/result_c/result_list/cats/3".

 

So far so good, everything working normally.

 

The problem arises in my need to be able to find items that match multiple tags.  To do this, I've added a dummy column to the tag list page which contains checkboxes, wrapped the whole list in a form that sends these checkboxes to the 'result_c' controller, and the controller uses them to generate the list.  If I set the form to "GET", the resulting URL looks like this: "index.php/result_c/result_list?boolean=and&submit=Search&...&selector[]=2&selector[]=4" (some irrelevant stuff trimmed out).  This indicates that what is desired is those items that have both the tag "2" and the tag "4".  The resulting list looks much the same as the one above, complete with a read button.  Everything works correctly to this point.

 

The problem arises when I click the View button.  That URL is now in the form ".../index.php/result_c/result_list/read/6961" (note lack of 'cats/3' from before), and when the "Back to List" button is clicked, the URL it tries to go to is in the form ".../index.php/result_c/result_list/" - note the lack of any data as to what tags to look at.  It completely loses the data previously in the screen's GET.  The same occurs if I change the form to POST - everything works, except the return from the view.

 

Does anyone know of a way to fix this?  To pass the "extra" data from the list view to the read view and then back to the list view?  This is a major issue for this project, that I need to resolve.

 

Thanks!