CJuiDatePicker altField update

Dear All,

I have a problem with CjuiDatePicker, I need to display the birthDate as ‘dd-mm-yyyy’ but mysql only accept ‘yyyy-mm-dd’. I use pure CjuiDatePicker solution instead of beforeSave/afterFind

This is my CJuiDatePicker




<?php

        $this->widget('zii.widgets.jui.CJuiDatePicker', array(

            'name' => 'dateOfBirth',

            'value' => $birthOfDate,

            'options' => array(

                'showAnim' => 'fold',

                'dateFormat' => 'dd-mm-yy',

                'altFormat' => 'yy-mm-dd',

                'altField' => '#Member_birthDate',

                'changeMonth' => 'true',

                'changeYear' => 'true',

                'yearRange' => '1920:+0',

                [color="#FFFF00"]'onSelect' => "js:function() {}",[/color]

            ),

            'htmlOptions' => array(

                'class' => 'small',

            ),

        ));

        echo CHtml::activeHiddenField($model, 'birthDate');



If I chose using datepicker, the $model->birthDate is updated as expected.

I need to add [color="#FFFF00"]‘onSelect’ => “js:function() {}”,[/color], If I want this solution is also works by typing the date into the textfield. Without this line, my datepicker will not update the $model->birthDate like situation if I pick the date from datepicker.

But still, I have issue, my browser keeps history of the date have been entered. If, I am not chosing from date picker or type the date, but select one from the history/cache, It eill not udpate the $model->birthDate.

Any hints, whout should I do?

If I add this checking in actionCreate in controller it works,




        if (isset($_POST['Member'])) {

            $model->attributes = $_POST['Member'];

            

            if(isset($_POST['dateOfBirth']) && $_POST['dateOfBirth'] != '') {

                $model->birthDate = date('Y-m-d', strtotime($_POST['dateOfBirth']));

            }



but I am not quite happy since it means my pure CJuiDatePicker is useless. Adding ‘autocomplete’ => ‘off’ in the form would be another option. But any comment or other suggestion?