Welcome Guest, Not a member yet? Register   Sign In
Form re-population with no rules set
#1

[eluser]dmitrybelyakov[/eluser]
Hey!

I experience some problems with new 1.7.0 Validation Class.
When i re-populate the form with submitted data it doesn't actually show up if the field has no rules attached in the controller (with set_rules() function). It may have any rule attached - like required trim or just anything. It just has to be there in the rules list.

This seems strange. Am I the only one who has this problem?

I did some testing with examples from the manual (controller & form view) and the problem remains.
If i remove validation from any of the fields in the tutorial - re-population stops working.

Is this the correct behavior?
#2

[eluser]Phil Sturgeon[/eluser]
If a form input has no validation it will not be a property of the validation library like the rest. You can pick these values up with $this->input->post() instead.

That problem has been around a while sadly, but it makes a certain amount of sense. If you don't tell validation about an input, why should it look for it?
#3

[eluser]dmitrybelyakov[/eluser]
A small addition to my previous post: if you enable Profiler in your constructor you might see that all data is in the _POST array. Bu still re-population doesn't work.
#4

[eluser]dmitrybelyakov[/eluser]
[quote author="pyromaniac" date="1229377447"]If a form input has no validation it will not be a property of the validation library like the rest. You can pick these values up with $this->input->post() instead.

That problem has been around a while sadly, but it makes a certain amount of sense. If you don't tell validation about an input, why should it look for it?[/quote]


So if i get your point: we are forced to use some odd validation rules like trim for a <select> value if we want to use re-population feature, right?
#5

[eluser]Phil Sturgeon[/eluser]
Would seem so, that is how it has been through 1.5.x and 1.6.x, not tried the new Validation library in 1.7 yet.
#6

[eluser]Michael Wales[/eluser]
You can just use a blank ruleset and it will allow you to use the repopulation functions correctly..

Code:
$this->form_validation->set_rules('email', 'Email Address', '');

Code:
&lt;input type="text" name="email" id="email" value="&lt;?php echo set_value('email'); ?&gt;" /&gt;
#7

[eluser]jalalski[/eluser]
You don't even need the label:
Code:
$this->form_validation->set_rules('email', '', '');

Smile
#8

[eluser]dmitrybelyakov[/eluser]
reminds me of set_fields() function




Theme © iAndrew 2016 - Forum software by © MyBB