⚠ 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

Pre-filling form with previous values



itod
  • profile picture
  • Member

Posted 25 February 2016 - 11:52 AM

Hi,

 

I have a form with multiple fields sharing values with previous records. Almost always only 2 of more then a 10 fields are changed for series of dozen rows, rest of them stay the same. Is it possible to somehow pre-fill all the values in the form with values user previously entered, and let him change only those 2 instead of forcing him to enter everything all over again?

 

Another solution would be to add another button next to [view] [edit] [delete], named [copy] which would copy that row and then let the user change some values.

 

Does anyone have any of these solutions implemented? If not, what would you suggest to be simpler one to try to implement in Grocery CRUD?

 

Thanks,

itod


titu
  • profile picture
  • Member

Posted 25 February 2016 - 13:50 PM

I have implemeted both cases.

 

The first one entering default values with javascript:

 

/topic/3048-default-values-select-and-text/

 

and the second one cloning rows by duplicating database record and then open edit form.


itod
  • profile picture
  • Member

Posted 25 February 2016 - 18:26 PM

Thanks, I see how you've done that. Slight problem is I have 3 other tables in the database, and those other tables don't have repeatable rows, so i should put your function on the button to be explicitly called when desired instead of being called for all tables, but that should be easy.

 

Can you please post the other solution with cloning rows button in the list, it looks that would be even better?

 

Thanks,

itod


titu
  • profile picture
  • Member

Posted 26 February 2016 - 01:07 AM

If $output->textDefault or $output->selectDefault are not defined no code will be executed so no matter how many tables you have.

 

The downside of cloning is that you are inserting a new row and if the user cancels you should delete that row.

 

Whats is your question? about cloning? just run a select and insert all values and after redirect the user to "/controllers/method/edit/insert_id"


itod
  • profile picture
  • Member

Posted 26 February 2016 - 09:31 AM

Ok, will do it that way, thanks for advice.


Amit Shah
  • profile picture
  • Member

Posted 29 February 2016 - 14:14 PM

Please find a relevant solution for the same on the following link

http://grocerycrud.amitsgarage.com/bwl-knowledge-base/copy-new-row/