Smart way to keep input data after form success |
Hi all,
I'm looking for the smartest way to repopulate a form after a success submit. My use-case is a search form, for which the more convenient for users is to have their last search param kept in the input fields. Of course I can do it by myself passing the value to the view, but I was wondering if there is something like the set_value() function that I can use in my case. Thanks in advance, ponsfrilus
++ ponsfrilus
Look at the docs for the form_validation library. They show how to do this with set_value() in the "Re-populating the form" section.
(02-24-2015, 11:14 AM)ponsfrilus Wrote: Hi all, You can set a session flash data with the value of the input field and then just output it inside the search form. Website: http://avenir.ro
(02-24-2015, 11:14 AM)ponsfrilus Wrote: ...after a success submit. As said in the form_validation documentation the set_value() function is working only if the form have validation and the ->run() trigger an error: Quote:Now reload your page and submit the form so that it triggers an error. Your form fields should now be re-populated My question was related to a success form. Is there a way to set validation without specifiying any rules to use built-in set_value() or do I need to do it in another way. I want my users being able to recover their search params in order they can modify them. Thanks, ponsfrilus
++ ponsfrilus
So it seems that the set_rules() function can accept only one arg, so the minimal code could be:
PHP Code: $this->load->library('form_validation'); which allows the form not to have validation but it can still re-populate "my_field" with the posted value. What do you think ? Thanks, ponsfrilus
++ ponsfrilus
|
Welcome Guest, Not a member yet? Register Sign In |