Validation v/s Form_Validation |
[eluser]Yash[/eluser]
In old validation Code: $this->input->post('name'); In Form validation Code: $this->input->post('name'); //works This is not a Qs really just curious why not we can't access field like this.
[eluser]pistolPete[/eluser]
Just compare the two classes: In Validation.php each form field is saved as a private class variable. In Form_validation.php the form fields are saved in a private array called $_field_data.
[eluser]Yash[/eluser]
ok I can see that so how can I access Code: $this->form_validation->name; something like this? Code: $this->form_validation->array['name'];
[eluser]pistolPete[/eluser]
Why don't you just use the form helpers? http://ellislab.com/codeigniter/user-gui...elper.html set_value(), set_select(), etc.
[eluser]Yash[/eluser]
I know that as well. I want give value from controller with a initial value. Like we want to do in edit case. also when we are using callback function(s) if we need to access 2 fields then $this->validation->name would be very handy..any alternate to this? Code: // Check username/email for uniqueness
[eluser]LuckyFella73[/eluser]
You can set an initial value using the form_validation like this: Code: <?php In your controller you just need to check if your edit function is called from your form - then set the $data['abcd'] part via your POST data instead of db values. Your callback function is only needed after submitting the form, so you can use (for example): Code: $this->input->post('title') Cheers
[eluser]Phil Sturgeon[/eluser]
Wow, I really need to convert PyroCMS to use the new form validation library, the syntax and helper functions cut out A LOT of extra code!
[eluser]Yash[/eluser]
@luckyfella73 You are setting 2 times same value what I'm saying that I set value once. I know what you're suggesting me. I'm currently using this. anyone...
[eluser]LuckyFella73[/eluser]
[quote author="Yash" date="1251385063"]@luckyfella73 You are setting 2 times same value [/quote] Where do set the same value? I just posted a bit code where the controller set the initial value comming from database. After submitting your form the "value-parameter" of your form element has to be set using the post data. In your controller/ edit function you need something like that: Code: <?php There are two parts in the code that set a form value but thats the way you have to go if you want to edit data from db using a form because the source of the values are different. Sorry if I get you wrong completely |
Welcome Guest, Not a member yet? Register Sign In |