![]() |
Using the Validation Library - 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: Using the Validation Library (/showthread.php?tid=9377) |
Using the Validation Library - El Forum - 06-23-2008 [eluser]Walt Kirspel[/eluser] I just want to see if I am in the ballpark here. I've figured out how the rules work. And how set_fields works to repopulate the post data. My question refers to how I best provide default data for the fields the first time around. Code: $data['title'] = 'Setup'; I pass the $data variable into the form for things like titles and stuff. But for the input data in the form I use $this->validation->sourcepath and $this->validation->destpath. My question is really in regards to how I handle the default data I want populated the first time through. What I did was check the $this->validation->sourcepath field after I had executed set_fields. Because I was assuming that if set_fields didn't have anything to populate from the post I could drop the default data into the fields. But I also realize that although it semi "works", if the user has cleared the field it will still look to me as the first pass thru. So I'm not sure I've handled it the best way possible. Is there some fairly "standard" approach folks utilize? Thanks. Walt Using the Validation Library - El Forum - 06-23-2008 [eluser]Colin Williams[/eluser] I think one thing CI is certainly lacking is a handler for this exact usage case. This comes up on every project, and I usually come up with a more clever way to handle it each time. I know someone has already extended the Validation library to handle this, I think with something like $this->validation->set_defaults($defaults) [.. just an example of how I think it's implemented.] Try searching this forum or the Wiki. I know it's been done. Using the Validation Library - El Forum - 06-24-2008 [eluser]thinkigniter[/eluser] This may help! Using the Validation Library - El Forum - 06-24-2008 [eluser]Dagobert Renouf[/eluser] Your post is great cjunky, however I don't think this is what Walt is looking for. Here's what Colin is talking about : http://ellislab.com/forums/viewthread/47337/#228374 Using the Validation Library - El Forum - 06-24-2008 [eluser]Walt Kirspel[/eluser] [quote author="Dagobert Renouf" date="1214331918"]Your post is great cjunky, however I don't think this is what Walt is looking for. Here's what Colin is talking about : http://ellislab.com/forums/viewthread/47337/#228374[/quote] Thanks. Helps a lot! |