Fuel model validate

edited March 2014 in Bug Reports
Afternoon,

Not sure if this is a bug or not. I've updated my Fuel to one of the most recent versions and now in one of my modules in Fuel, when I submit a form with an email field it's validating with "Please enter in a valid email address".
This is good, except the email address is valid.

Where in the code do I look to see where it's accepting the validation?
The email address is passed on after on_before_validation() but doesn't arrive at on_before_save() without the validation error.

Any ideas?

Thanks,
Chris.

Comments

  • edited 5:49AM
    By default, there is an auto_validate_fields property that uses a regular express to look for fields containing "email" or "email_address" in them. Do you by chance have another field with the word "email" in it somewhere that it may be trying to validate? You could setting the $auto_validate_fields to just an empty array. By default it is set to this;
    public $auto_validate_fields = array( 'email|email_address' => 'valid_email', 'phone|phone_number' => 'valid_phone' );
  • edited 5:49AM
    I adjusted the auto_validate_fields accordingly so it would ignore the 'email' field.
    I also looked for a duplicate 'email' field, I found one that had 'email' in it, but wasn't relevant.
    I was just trying to dig into the code to find out where it was coming up with the error between on_before_validate and on_before_save.
  • edited 5:49AM
    The one with 'email' in it could trigger the error. Were you able to figure it out.
  • edited 5:49AM
    Okay, so if I unset my field 'validated_email' in on_before_validate() I can't update that field, but my 'email' field works perfectly, no errors.

    How can I have both then?

    I tried specifying $auto_validate_fields = array('email' => 'valid_email'); but it's still picking up the other field.
  • edited 5:49AM
    It's a regular expression value so you can anchor the beginning and end by do something like this:
    public $auto_validate_fields = array( '^email$' => 'valid_email', );
  • edited 5:49AM
    Ah, now that makes sense! I didn't even think of it being a regular expression. That worked perfectly.

    Again, thanks!
Sign In or Register to comment.