CJuiDatePicker widget from Yii issue
Solution 1
See if you have a text field on the page with the same name eg. in advanced search form.
If you have two fields on the same page with the same name, datepicker will show only for one of them.
Regards
Solution 2
Let yii decide the name for you automatically using the model
property of the parent CJuiInputWidget class, so you can do this:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
// 'value'=>$model->issued_date, // pre-fill the value
// instead of 'value' use 'attribute'
'attribute'=>'issued_date',
// additional javascript options for the date picker plugin
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'defaultDate'=>$model->issued_date,
'buttonImage'=>Yii::app()->baseUrl.'/images/icons.date.png',
'buttomImageOnly'=>true,
'buttonText'=>'Select',
'showAnim'=>'fold',
'showOn'=>'button',
'showButtonPanel'=>false,
'yearRange'=>'1900',
'debug'=>true,
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
Edit:
Since you are modifying a generated form, you can put the above part where there was the gii generated textField, and leave the other lines for this field the same, example:
<?php echo $form->labelEx($model,'issued_date'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker'), array(// your datepicker options
);?>
<?php echo $form->error($model,'issued_date'); ?>
Solution 3
<?php
$this->widget(
'zii.widgets.jui.CJuiDatePicker',
array(
'name' => 'order_date',
'value'=>Yii::app()->getRequest()->getParam("order_date"),
'language' => Yii::app()->language == 'et' ? 'et' : null,
'options' => array(
'showAnim' => 'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
'showOn' => 'button', // 'focus', 'button', 'both'
'buttonText' => Yii::t('ui', 'Select form calendar'),
'buttonImage' => Yii::app()->request->baseUrl . '/images/calendar.png',
'buttonImageOnly' => true,
),
'htmlOptions' => array(
'style' => 'width:80px;vertical-align:top'
),
)
);
?>
PartySoft
Updated on June 04, 2022Comments
-
PartySoft almost 2 years
I am trying to integrate the DatePicker to a generated CRUD form on edit When I put the name as an array (like the textField generates) it won't popup the calendar If I use a simple name (non array) it works... If I quit completly the name it doesn't work
I'm using Yii 1.8
here's my code
$this->widget('zii.widgets.jui.CJuiDatePicker', array( // 'name'=>'birthdate', 'name'=>"MainVendorsInvoices[issued_date]", // the name of the field 'value'=>$model->issued_date, // pre-fill the value // additional javascript options for the date picker plugin 'options'=>array( 'dateFormat'=>'yy-mm-dd', 'defaultDate'=>$model->issued_date, 'buttonImage'=>Yii::app()->baseUrl.'/images/icons.date.png', 'buttomImageOnly'=>true, 'buttonText'=>'Select', 'showAnim'=>'fold', 'showOn'=>'button', 'showButtonPanel'=>false, 'yearRange'=>'1900', 'debug'=>true, ), 'htmlOptions'=>array( 'style'=>'height:20px;' ), ));