CodeIgniter Forums
Return manipulated form data from model to controller. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Return manipulated form data from model to controller. (/thread-54792.html)



Return manipulated form data from model to controller. - El Forum - 09-25-2012

[eluser]Unknown[/eluser]
Hey Everybody,
I'm using the excellent form generation library and have forms submit to a function in MY_Model that takes the data and table name and runs a bunch of tests and array manipulation. One of which determines whether it's an update or insert statement and saves the $data['ID'] or $this->db->insert_id() and returns the entire array. The end goal is to have a validated form in the controller redirect the url to /path/to/ID/# and always be right, regardless of it being a new insert or an update function. I also have a problem when a secondary insert happens after the initial query, in which case $this->db->insert_id() returns the wrong ID in the controller.

Any ideas? I'm trying to avoid running test to see if $this->db->insert_id() is set on each and every form, probably 3-400 in total. Thanks for your help and a wonderful product!


Return manipulated form data from model to controller. - El Forum - 09-25-2012

[eluser]TWP Marketing[/eluser]
We're going to need to see some of your code and any errors you are getting (browser, apache, php etc.)

I'm not sure exactly which path you are using in your form in the action parameter. Normally this will point at a Controller method and not a model function, which is how I could interpret your post. Could you give us an example please?