Welcome Guest, Not a member yet? Register   Sign In
Repopulating form fields
#1

[eluser]frist44[/eluser]
I'm using some validation rule sets on my form and I'm noticing that <?=set_value('name')?> only works on fields that were validated. I have some fields that aren't necessarily required, but I'm putting some much less restrictive rule on them just to get the set_value function to work. Is there a helper-style rule to repopulate fields that do not include a validation rule?

Thanks!
#2

[eluser]flaky[/eluser]
instead of
Code:
<?=set_value('name')?>
put
Code:
<?=$this->input->post('name');?>;
#3

[eluser]Neeraj Kumar[/eluser]
I would really suggest you to use validation on non required fields also. Using CI's native functions will keep your app clean.
#4

[eluser]Ollie Rattue[/eluser]
[quote author="Codemaster Snake" date="1262211215"]I would really suggest you to use validation on non required fields also. Using CI's native functions will keep your app clean.[/quote]

Yes I would agree that you should use CI validation for all form fields, as it makes the controler code completely clear. If you don't need a field to be required you can in fact set a fieldname without any validation rules, or as I usually do with xss_clean and trim. Example code:

Code:
$this->form_validation->set_rules('location','Location','');            
$this->form_validation->set_rules('cinema_name','Cinema Name','required|trim|xss_clean');            
$this->form_validation->set_rules('booking_url','Booking url','trim|xss_clean');
$this->form_validation->set_rules('phone_number','Phone number','trim|xss_clean');
$this->form_validation->set_rules('email_address','Email address','trim|xss_clean');
#5

[eluser]Neeraj Kumar[/eluser]
@ollie is absolutely correct, check the way he omitted the 'required' from the list
#6

[eluser]frist44[/eluser]
If you enable the xss global setting in the config file, those xss_clean rules can be removed from individual rules right?
#7

[eluser]Ollie Rattue[/eluser]
[quote author="frist44" date="1262226186"]If you enable the xss global setting in the config file, those xss_clean rules can be removed from individual rules right?[/quote]

Correct.




Theme © iAndrew 2016 - Forum software by © MyBB