Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:01:31+00:00 2026-06-14T14:01:31+00:00

Hi have a problem with the rules() method of one of my application model.

  • 0

Hi have a problem with the rules() method of one of my application model.

Here is rules():

public function rules() 
{ 
  $newRules = array(
    array('password_verification', 'required'),
    array('password_verification', 'length', 'min'=>6, 'max'=>32),
    array('password', 'compare', 'compareAttribute'=>'password_verification'),
    array('username, email', 'length', 'min'=>3,'max'=>255),
    array('password', 'length','min'=>6, 'max'=>32),
    array('username, email', 'unique'),
    array('email', 'email'),
    array('valid_until_formated','compare', 
          'compareAttribute'=>'valid_from_formated','operator'=>'>'),
    array('id, type,username, password, password_verification, email, valid_from, valid_until, valid_until_formated, valid_from_formated, added_on, created_by','safe'),
  );
}

(sorry for the format of the code).

And here is the problem:

I want to test if "valid_until_formated" is greater than "valid_from_formated".

When I submit my form with wrong values (valid_from greater than vali_ until) I get an error message, I can see it on firebug but the values are inserted in data base.

But for instance if I try with a username already used or a password with fewer character than 6 then I have an error and nothing is created in database?

Does anybody have an idea why this rule doesn’t work (even if I get an error message) ?
(this is the format of valid_until_formated, for example: "20121118" )

Thanks for reading me and sorry for my approximate English.

Have a good day 🙂

Michaël

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:01:32+00:00Added an answer on June 14, 2026 at 2:01 pm

    Thanks you all for your answer.

    Actually it was a dump mistake I did.

    I didn’t know the validate() method was call by the save() one. Actually I was trying to save a User and I didn’t understand why the rules in my CustomUser model were not run –_-.

    The test was on my User:rules() and my CustomUser::rules() inherits my User::rules()…Anyway I fixed this issue like that.

    if(myCustomUser->validate()){

    myUser = new User;

    … …

    myUser->save(false);

    }

    Like that I can create a user with the validation rules of my CustomUser.

    Thanks, Have a nice day 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with show or hide form in Window Form Application. I start
I have a 2 tabs application. In the first one, I'm creating objects of
I have a method that zips up one or more files using DotNetZip, and
Please help me to resolve the following problem: First of all, I have one
The problem A friend is developing a Swedish dictionary web application . One use
I have a problem with the code analysis rule CA1726:UsePreferredTerms . Our business domain
i have a problem to order a list by certain rule. Actually i have
I have a problem, I have the next controller namespace RolesMVC3.Areas.Administrador.Controllers { [Authorize(Roles =
Today I have had a problem with hiding text with text-indent: -9999px rule. I
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.