Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 - Form_Validation
#1

[eluser]Mat-Moo[/eluser]
I'm still a newb, but I've been changing my forms from Validation for Form_validation and I think I found a minor bug Smile (BTW love the new Form_validation, so much neater/quicker!)

Code:
$this->form_validation->set_rules('fpassword','Password','trim|required|min_length[6]|max_length[32]|xss_clean');
$this->form_validation->set_rules('fpasswordverification','Password verification','trim|required|min_length[6]|max_length[32]|xss_clean|matches[fpassword]');

When I run a validation on this, when they do not match I get "The Password verification field does not match the fpassword field." so it looks as though the "matches" puts the field actual name rather than the display name in.
#2

[eluser]Huan[/eluser]
I have had the same problem

With previous versions of CI (CI 163 and CI 170 SVN), this code worked:

Code:
<select name="parent_node">
    <option value="">None</option>
&lt;?php if (isset($parent_nodes)){ foreach ($parent_nodes as $pn){ ?&gt;
    <option value="&lt;?=$pn['full_uri']?&gt;" &lt;?php echo set_select('parent_node', $form_parent_node, $form_parent_node==$pn['full_uri'])?&gt;>&lt;?=$pn['title']?&gt;</option>
&lt;?php }} ?&gt;
</select>

($form_parent_node is correctly set)

But after upgrading to CI 170 release, no option is selected. I had to change it to:

Code:
<select name="parent_node">
    <option value="">None</option>
&lt;?php if (isset($parent_nodes)){ foreach ($parent_nodes as $pn){ ?&gt;
    <option value="&lt;?=$pn['full_uri']?&gt;" &lt;?php if($form_parent_node==$pn['full_uri']) echo 'selected="selected"';?&gt;>&lt;?=$pn['title']?&gt;</option>
&lt;?php }}?&gt;
</select>


to make it work again.

Dont know why.
#3

[eluser]vittee[/eluser]
I have the same problem with "matches" rule.

So I edited the libraries/Form_validation.php at line 666
from
Code:
// Build the error message            
$message = sprintf($line, $this->_translate_fieldname($row['label']), $param);

to

Code:
// Build the error message                        
$mparam = ( ! isset($this->_field_data[$param])) ? $param : $this->_field_data[$param];                
$message = sprintf($line, $this->_translate_fieldname($row['label']), $mparam['label']);

Hope this helps.

Best regards.
#4

[eluser]dmiden[/eluser]
Ah, I posted a solution to this in the main category, sorry for that Smile
I fixed this by editing line 666 in libraries/Form_validation.php:
Code:
$message = sprintf($line, $this->_translate_fieldname($row['label']), $param);
to:
Code:
$mfield = ( isset($this->_field_data[$param]) ) ? $this->_translate_fieldname($this->_field_data[$param]['label']) : $param;
$message = sprintf($line, $this->_translate_fieldname($row['label']), $mfield);
#5

[eluser]dmiden[/eluser]
Hm, the difference between my fix and vittee's is that his/her doesn't translate the label if supposed to.
#6

[eluser]vittee[/eluser]
I suggest that dmiden's fix is better than mine.
#7

[eluser]Douglas Clifton[/eluser]
Thank you, I was searching for a fix for this rather strange bug. I noticed it in particular when the field [id] string had an underscore character in it.
#8

[eluser]augustowloch[/eluser]
thank you people! i was looking exactly for this! on vittee's solution, i got a problem with 'max_length', because it trimmed the number to 1 char, but with dmiden it works perfectly! thank you all, again!
#9

[eluser]Mat-Moo[/eluser]
I believe this is fixed in CI 1.7.1 anyway now...
#10

[eluser]pistolPete[/eluser]
[quote author="Mat-Moo" date="1234710651"]I believe this is fixed in CI 1.7.1 anyway now...[/quote]
Don't think so, the line is still there in CI 1.7.2 SVN.




Theme © iAndrew 2016 - Forum software by © MyBB