wvActiveForm is a CActiveForm descendant that validates the input on client with jQuery, using the rules defined at the model, while also supporting custom rules.
it seems like a promising extension ! however, I tested it following your instructions, and I get the error :
Fatal error: Call to undefined function lcfirst() in H:\home\Project\yii.1.2\protected\extensions\wvactiveform\wvFormRules.php on line 48
ciao
ps: you’re right about jformvalidate not supporting CActiveForm Widget, and I’ve been thinking about releasing a new version that would support CActiveForm Widget…
Hmm you’re right, lcfirst function only exists in PHP 5.3+, I’ve released a new version without this call.
About jformvalidate, as I started working with Yii 1.1, all my code was already using CActiveForm, so I want a method of upgrading all my applications with a minimum effort, that’s why I created this extension.
Also, I wanted to make it easy for 3rd party developers create his own rules as extensions, again always thinking of minimum code changes.
Hmm I think the main problem is, Yii doesn’t take allowEmpty in account when checking for required fields (CModel::isAttributeRequired), and also doesn’t add the ‘*’ on the field’s label:
public function isAttributeRequired($attribute)
{
$model=$this->resolveAttribute($attribute);
foreach($model->getValidators($attribute) as $validator)
{
if($validator instanceof CRequiredValidator)
return true;
}
return false;
}
This "allowEmpty" conflicts with the required validator, but on the case of a form, the field IS required when allowEmpty is false, so I think your patch is correct.
Hmm are you sure about this? Are you calling this method directly? Because it is only called in the "checkValidation" method, and it already does this.