Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

form validation matches problem #1957

Closed
hakimihamdan88 opened this Issue · 10 comments

4 participants

@hakimihamdan88

form validation matches bug

@narfbg
Owner

And the bug is ... ?
Come on man, it's not like this is your first bug report.

@hakimihamdan88

form validation still output "not match" when matched

@narfbg
Owner

Still? Since when? Can you show code?

@hakimihamdan88
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
if ($this->form_validation->run()) {
}
<?php echo validation_errors(); ?>

<?php echo form_open('welcome'); ?>

<h5>Password</h5>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />

<h5>Password Confirm</h5>
<input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" />

<div><input type="submit" value="Submit" /></div>
@it-can

The matches rule needs to be at the end...

$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');
if ($this->form_validation->run()) {
}

@narfbg
Owner

Has that ever worked in that particular order?

@hakimihamdan88

ah now it works.
now i need to change all the code. how come suddenly change
http://codeigniter.com/nightly_user_guide/libraries/form_validation.html still use

$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
@GDmac

I downloaded the oldest version available of CI, and indeed, it has always been in the wrong order in the docs.
(edit: the docs were right, the matches method has changed)

This breaks backward compatibility with 2.x.!
Declaring matches[] first has always been perfectly valid.
The matches() method has changed from comparing $str to $_POST[$field],
and it now compares $str against set form data: $this->_field_data[$field]['postdata']

@GDmac

@narfbg the way the matches() method matches, doesn't match 2.x, it breaks backward compatibility.

@narfbg narfbg closed this issue from a commit
@narfbg narfbg Fix #1957 751f247
@narfbg narfbg closed this in 751f247
@GDmac

@narfbg , thanks, nice , a "matching" workaround.

@nonchip nonchip referenced this issue from a commit in nonchip/CodeIgniter
@narfbg narfbg Fix #1957 227526d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.