new validation library autocomplete field - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: new validation library autocomplete field (/showthread.php?tid=12704) |
new validation library autocomplete field - El Forum - 10-28-2008 [eluser]Bogdan Tanase[/eluser] Hi guys, I'm trying to write a form using the new validation library, and I'm a little confused on how I should implement an "edit" feature. I use the same view for add and edit and two functions in my controller: add and edit. In the old library in the edit function I was using the following code to autocomplete edited fields when edit function was first called: Code: // the validation rules and fields are already set in my view I had something like this: Code: <?=form_input('name', $this->validation->name)?> now, I understand that, with the new library, in the view I set the values using set_value, but how do I set them in the controller, to be used then by the set_value function? Thanks, Bogdan new validation library autocomplete field - El Forum - 10-28-2008 [eluser]Bogdan Tanase[/eluser] Later edit: I looked again. this does soemthing else After looking through the form_validation.php file it looks like the member function set_value should do the trick: Code: $this->form_validation->set_value('name', $current_item->name); However, this doesn't work. What am I missing? new validation library autocomplete field - El Forum - 10-31-2008 [eluser]Volder[/eluser] hello, have you found the solution to your problem? Because I'm facing the same problem. In previous version of CI 1.6.3 I used in my controller conditions like: Code: If ($this->validation->email) but how to get the value from the input form to use inside controller now with 1.7.0? set_value('email') is not working. even simple Code: echo set_value('email'); new validation library autocomplete field - El Forum - 10-31-2008 [eluser]Bogdan Tanase[/eluser] Hi, Regarding the problem in my initial post, in the new version you can no longer set the validation fields. I had to use another approach, by passing the variables in the edit function (controller) to the view, and then display it using set_value: Code: //controller view code Code: //... But your problem is different. The code you posted should work. Did you set the rules as described in the manual? Code: $this->form_validation->set_rules('email', 'Your email', 'required|valid_email'); new validation library autocomplete field - El Forum - 10-31-2008 [eluser]Volder[/eluser] Yes, I did it in a proper way. BTW I found a thread with a question similar to mine. The suggestion there was to use $this->input->post('field_name') instead. It worked for me. new validation library autocomplete field - El Forum - 12-06-2008 [eluser]MeanStudios[/eluser] This will not work: Code: echo set_value('email'); Code: echo $this->form_validation->set_value('email'); |