This extention simplifies creation of three dropDownLists for collecting dates on models. Combines ehtmldataselect (manipulates dates under 1970-01-01) and activedatelist (adds behavour for onBeforeValidate).
Requirements ¶
works fine on Yii 1.1.7 or above
Installation ¶
Extract the release file under protected/extensions
Usage ¶
in view:
$this->widget('ext.ActiveDateSelect',
array(
'model'=>$model,
'attribute'=>'birthdate',
'reverse_years'=>true,
'field_order'=>'DMY',
'start_year'=>1910,
'end_year'=>date("Y",time()),
)
);
in controller:
$model=new User;
if(isset($_POST['User'])){
$model->attributes=$_POST['User'];
ActiveDateSelect::sanitize($model, 'birthdate');
if($model->validate()){
$model->save();
...
}
}
Don't forget to import the class to your controller or to add the extention directory to your main config.
Great
but you should import before use in controller
$model=new User; if(isset($_POST['User'])){ $model->attributes=$_POST['User']; Yii::import('ext.ActiveDateSelect'); // add this line** ActiveDateSelect::sanitize($model, 'birthdate'); if($model->validate()){ $model->save(); ... } }
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.