hi there… i am very new to this yii framework…
i have some problems in making forms… i created forms in CRUD generator and the results are i have all text fill in forms… i want to change some text field forms to date pickers form but i’ve failed to do so…
here are my codings;
<div class="row">
<?php echo $form->labelEx($model,'PROG_ENDDATE'); ?>
<?php echo $form->textField($model,'PROG_ENDDATE'); ?> //i want to change this into date picker.. please help
<?php echo $form->error($model,'PROG_ENDDATE'); ?>
</div>
thank you in advance…
wshaman
(Rakoth Android)
February 25, 2015, 4:56am
2
yusfriyusop:
hi there… i am very new to this yii framework…
i have some problems in making forms… i created forms in CRUD generator and the results are i have all text fill in forms… i want to change some text field forms to date pickers form but i’ve failed to do so…
here are my codings;
<div class="row">
<?php echo $form->labelEx($model,'PROG_ENDDATE'); ?>
<?php echo $form->textField($model,'PROG_ENDDATE'); ?> //i want to change this into date picker.. please help
<?php echo $form->error($model,'PROG_ENDDATE'); ?>
</div>
thank you in advance…
take a look at this page please:
yii\jui\DatePicker
So, you’ll end up with something like this:
<div class="row">
<?php echo $form->labelEx($model,'PROG_ENDDATE'); ?>
<?php echo DatePicker::widget(['model' => $model,'attribute' => 'PROG_ENDDATE',]); ?>
<?php echo $form->error($model,'PROG_ENDDATE'); ?>
</div>
Um… sorry, if you’re on yii1.*, you should follow this link:
CJuiDatePicker
But I(and many others, you know) would strongly recomend you to start with yii2.
Thank you for your help…
now the problem is, when i save the date, it does not appear in my view… it says ‘not set’…
this is my coding
<div class="row">
<?php echo $form->labelEx($model,'PROG_STARTDATE'); ?>
<?php echo $form->textField($model,'PROG_STARTDATE'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'name'=>'PROG_STARTDATE',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'dd-mm-yy',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
the date i want does not appear in my database too…
wally
(Fosales)
February 26, 2015, 2:39am
4
Hi,
I think the problem happens because the date’s format is different:
This behavior can help you: http://www.yiiframework.com/extension/i18n-datetime-behavior/
yes thank you… i have changed it thank you so much…
these are my codings in form.php
<?php echo $form->textField($model,'PROG_ENDDATE'); ?>
<?php
//in _form.php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'PROG_ENDDATE',
'attribute' => 'PROG_ENDDATE',
'model'=>$model,
'options'=> array(
'showAnim' => 'fadeIn',
'dateFormat' =>'dd-mm-yy',
'changeMonth' => true,
'changeYear' => true,
),
))
?>
and the other one at ../model/ folder
//in model (e.g Program)
public function beforeSave()
{
$this->PROG_STARTDATE = date("Y-m-d", strtotime($this->PROG_STARTDATE));
$this->PROG_ENDDATE = date("Y-m-d", strtotime($this->PROG_ENDDATE));
$this->PROG_SUBMITDATE = date("Y-m-d", strtotime($this->PROG_SUBMITDATE));
return parent::beforeSave();
}