So I have a model attribute attributeName with an AttributeType::Number

I haven't implemented any personal validation rules yet, however when I run: model->validate(), its giving me a "attributeName must be an integer" error.

Is this just the default validation rule of the AttributeType::Number? and if so, is there anything I can do to make it accept floats?

I am trying to use this attribute for a price, I should note.

CNumberValidator has an integerOnly attribute, so I tried setting 'integerOnly'=>false in the attribute declaration, to no avail. Not sure if its relevant, I think I might be grasping at straws. Any help would be greatly appreciated!


Not really documented anywhere, but AttributeType::Number can accept an array of options, including min, max and decimal. You're looking for the last one.

AttributeType::Number => array('min' => 0, 'max' => 10, 'decimals' => 2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.