My MySQL have birthdate DATE
field for users. But in FORMs it show it as one simple text field.
<?=echo $form->textField($model,'birthday')?>
There is any way to Yii recognize DATE and format 3 select fields day/month/yeah? I used cakephp and it did automatically, helping a lot the development.
No there is no automatic way that Yii does this. The easiest way to do this is to add 3 more fields to the model controlling the form, some thing like:
date_year
date_month
date_day
You can setup the rules to handle the ranges/limits/types in the model. On the form you can then use those 3 models as test inputs. Once the form is submitted (most likely to your controller/action) you can then concatenate the 3 new model attributes to form the string/timestamp for your original model attribute:
$model->birthdate = $model->date_year."/".$model->date_month."/".$model->date_day
Another alternative is to use jQuery UI datepicker (which is built into Yii by default)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.