⚠ 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

Two different edit screens?



jgalak

jgalak
  • profile picture
  • Member

Posted 12 January 2014 - 00:22 AM

Is there any way to generate two different edit screens, with different field sets, depending on what button is pressed?  In other words, I want two different "Edit" buttons", each of which triggers Grocery CRUD's edit screen, but with different settings. 

 

I know I can do this by writing my own views and just creating the appropriate actions, but I'd really rather leverage the view already in Grocery CRUD...


ssfthurber

ssfthurber
  • profile picture
  • Member

Posted 18 February 2014 - 19:02 PM

there are a couple of hacks that i've used to deal with "unusual "actions".

to add an action that does edit differently from the declarations you have in the CRUD, the new action would route to a URL that is the same as the edit url except that you have include a segment that the CRUD checks to determine the alternate edit field list. then use the trick elsewhere on this forum to clean up the URL. alternatively the action URL could go to a small function that sets a flag in sessions then redirects back to the edit URL and just have the CRUD look for that session flag to determine the field list.

i've had to do this sort of thing and a complex user registration process because, for example, you don't know the id of an added record at the time the success message is set so you can't use the message to jump yourself to the next step so instead i go to a redirector, and by then the id is knowable. ok i digress but you get the general idea. 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 February 2014 - 20:59 PM

Hi jgalak - well.. u know what button is being pressed...

so just in state of edit ($crud->getState() == 'edit) .... there u check what is the button being pressed

there is where - u can define the $crud->edit_fields ... for each condition / scenario....

this should solve the problem

Happy GCing :)