Hello,
I’m using a CJuiDatepicker and i want to get the date selected in a variable in order to use it in my query,
anyone knows how to do it please
thank you
Hello,
I’m using a CJuiDatepicker and i want to get the date selected in a variable in order to use it in my query,
anyone knows how to do it please
thank you
Try this:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => CHtml::activeName($model, 'firstDate'),
'model'=>$model,
'value' => $model->attributes['firstDate'],
'options'=>array(
'showAnim'=>'fold',
'dateFormat' => 'yy-mm-dd',
),
'htmlOptions'=>array(
'style'=>'height:20px;',
),
));
Thank you for your reply
i tried it annd i get this error
i’ve already declared firstDate in model, any suggestion please
thank you
Mhhh, most likely you are in the Model’s _form.php and there should be a field “firstDate”, right?
What happens if you try to echo that field with
echo $model->firstDate;
?
i’m sorry, noo firstDate is declared in the datepicker (name=‘firstDate’) i want to show the date selected with echo, i’ve tried
echo firstDate;
but it doesn’t work
ok, sorry. i thought you wanted to use the datepicker to pick a date to be saved in the DB.
i’m afraid its not that easy. since php-pages are rendered on the webserver, and displayed in html, you cant change variables without reloading the page - in php.
to get the selected date in a variable for further use, you could use an AJAX function call.
this could help you with that http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown/