Installation ¶
- Place EAgeValidator.php to /protected/extensions/validators/age/ or any convenient directory
- Add path alias of extension to import section if you dont want to use full paths to EAgeValidator in your models.
Usage ¶
#method of your model class, that you need to validate
public function rules()
{
return array(
# If you imported ext.validators.age.EAgeValidator or placed EAgeValidator.php
# to directory, that is imported (for example, protected/components)
array('your_birthdate_field_name1', 'EAgeValidator'),
...
# With options and full path to extension
array('your_birthdate_field_name2', 'ext.validators.age.EAgeValidator',
'minAge'=>16,
'maxAge'=>120,
'allowEmpty'=>false
),
...
);
}
License ¶
BSD
Contacts ¶
- Vitaliy Stepanenko
- email: mail@vitaliy.in
- icq: 950130
- skype: vitaliy.step
- blog
Integration with Yii User
Hello,
I am trying to add this to the Yii User module and I am having trouble making it work. I have tried adding it in the validators field on the profile field management and I have also tried adding it to the RegistrationForm model but neither way is working. Has anyone successfully added this to the Yii User module?
Client Validation
Hi,
How can I integrate with client validation?
if ($dayDiff < 0 or $monthDiff < 0) { $yearDiff--; }
This part of the code is wrong because you should only check the days if the $monthDiff == 0.
I changed to this:
`
phpif ($monthDiff < 0) {
$yearDiff--;
}
if ($monthDiff == 0 && $dayDiff < 0) {
$yearDiff--;
}
`
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.