CodeIgniter Forums
CI 1.7 - Form_Validation - 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: CI 1.7 - Form_Validation (/showthread.php?tid=12599)

Pages: 1 2


CI 1.7 - Form_Validation - El Forum - 10-24-2008

[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.


CI 1.7 - Form_Validation - El Forum - 10-25-2008

[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.


CI 1.7 - Form_Validation - El Forum - 10-26-2008

[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.


CI 1.7 - Form_Validation - El Forum - 10-26-2008

[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);



CI 1.7 - Form_Validation - El Forum - 10-26-2008

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


CI 1.7 - Form_Validation - El Forum - 10-27-2008

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


CI 1.7 - Form_Validation - El Forum - 02-04-2009

[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.


CI 1.7 - Form_Validation - El Forum - 02-14-2009

[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!


CI 1.7 - Form_Validation - El Forum - 02-15-2009

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


CI 1.7 - Form_Validation - El Forum - 02-15-2009

[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.