I am new to yii. I am following the tutorial here:
and created a new webapp called logonapp.
I wanted to use CJuiDatePicker for Hire Date so I just put the following code in logonapp/htdocs/protected/views/employee/create.php
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'Employee_hireDate',
'name'=>'Employee_leaveDate',
// additional javascript options for the date picker plugin
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'showAnim'=>'fold',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?>
The problem is that after inserting above code, an extra new textbox appear on the page. I just want put CJuiDatePicker into the existing hire date textbox element. Any advice would be helpful. Thanks !
I had exactly the same problem yesterday. I also thought that it will be easy to add CJuiDatePicker to an existing form filed. I haven’t got time to seek for an answer if it is possible at all? I’ve ended up with removing original input box (to which I wanted to attach CJuiDatePicker) and using the one provided by this class and placing / formatting it, so it would look the same as rest of form elements.
For all those situation, where you use it not related to a model. For example, in already discussed in some other thread, where I have two different date pickers not related to any particular model property, which are used to build date period and only that period is then compared to a model’s property.
And also, this is a behaviour learned when using jQuery before I get know to Yii. In pure jQuery you have create an edit box yourself and then bind a calendar to it. It is Yii helper (wrapper) that does this job for you, am I right?
And third: I am against limits anywhere. Therefore I think that binding option should be implemented, for example by adding another feature that would tell class if input which name was provided in name property already exists or should be recreated.
My ask about binding was only related to the fact that I was a little bit surprised that Yii will generate required input for me. I thought (with my experience from pure jQuery coding) that I have to create this edit myself and bind calendar to it. Just as I would do in pure HTML + jQuery. Nothing else.