![]() |
Form validation and re-population - Not Working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Form validation and re-population - Not Working (/showthread.php?tid=14180) |
Form validation and re-population - Not Working - El Forum - 12-21-2008 [eluser]jaswinder_rana[/eluser] Code Code: //Edit User Profile Then my form is (Not sure if I am doing it the proper way Code: <?php $this->load->view('header');?> It's populating because I am using $this->input->post(). If I try to do an echo on top of my view, it doesn't work. Code: echo set_value('id_country'); Thanks Form validation and re-population - Not Working - El Forum - 12-21-2008 [eluser]Henry Weismann[/eluser] Try: Code: <?php echo form_dropdown('id_country',$arr,set_value('id_country',$id_country)); Also why are you checking if the user is logged in twice. You may want to think of checking if someone is logged in inside your controller class's constructor method. That will save you time from not having to write that logic more then once and it will make your application run faster without needing to process that function more then once. Form validation and re-population - Not Working - El Forum - 12-22-2008 [eluser]jaswinder_rana[/eluser] Thanks. I found the error. That class is actually loading validation library in constructor. I was, by mistake, loading it again and it was overwriting actual object and was giving me problem. Thanks for that tip on Drop Down. I was hoping that there was another way to get Drop Down values rather than looping through object and creating array. Reason for checking login in the function is, there are other functions in the same class that maybe run even if user is not logged in like register(), login() etc. I am adding above code in DX_Auth library to let users to edit profile. thanks Form validation and re-population - Not Working - El Forum - 12-22-2008 [eluser]Henry Weismann[/eluser] [quote author="jaswinder_rana" date="1229986356"] Reason for checking login in the function is, there are other functions in the same class that maybe run even if user is not logged in like register(), login() etc. I am adding above code in DX_Auth library to let users to edit profile. thanks[/quote] Ok that makes sense but why do you check it again in the view? And you could create a controller for all non logged in views...for example the ones you mentioned (register, login etc...) would be in an auth controller or something like that. Form validation and re-population - Not Working - El Forum - 12-22-2008 [eluser]jaswinder_rana[/eluser] [quote author="Henry Weismann" date="1229989586"] Ok that makes sense but why do you check it again in the view?[/quote] I was checking in view just to be careful in case it's accessed directly not that it will help them much. Now that I think about it, I don't need it in CI because of the way it's designed as everything will go through route. |