hello sorry i have many many problem in new of yii (me is newbi)
I have mistake in create.
in my _form i have tiny and CJuidatePicker
-> in begin tiny is work but in begin my CJuiDatePicker not work
not it is the problem
now my proble come to me (heee )
if i create on clicl button Create Always in same form. i think my model can read so it redirect in same form. wah … what happend
in my _form
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'news-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'Subject'); ?>
<?php echo $form->textField($model,'newstitle',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'newstitle'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Time Expiyed'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
//'name'=>'newsdtime',
'model'=>$model,
'attribute'=>'newsdtime',
//'value'=>$model->newsdtime,
'options'=>array(
'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
'showOn'=>'button', // 'focus', 'button', 'both'
'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.gif',
'buttonImageOnly'=>true,
'changeMonth'=>true,
'onSelect'=>'js:function(dataText,inst){
$(\'#newsdtime\').val(dataText);
alert(dataText);
}'
),
'value'=>$model->newsdtime,
'htmlOptions'=>array(
'style'=>'width:80px;vertical-align:top',
// 'value'=>'3/3/2011',
),
));?>
<?php echo $form->error($model,'newsdtime'); ?>
</div>
<?php /*?><!--<div class="row">
<?php $this->widget('application.extensions.tinymce.ETinyMce', array(
'model'=>$model,
'attribute'=>'newstext',
'name'=>'newstext',
'plugins' => array(..... ),
)); ?>
<?php echo $form->error($model,'newstext'); ?>
</div>
--><?php */?>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
in controller
public function actionCreate()
{
$model=new News;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['News']))
{
$model->attributes=$_POST['News'];
if($model->save())
$this->redirect(array('view','id'=>$model->newsid));
}
$this->render('create',array(
'model'=>$model,
));
}
i think it can read this
if(isset($_POST['News']))
{
$model->attributes=$_POST['News'];
if($model->save())
$this->redirect(array('view','id'=>$model->newsid));
}
so it only in form create
… so must i do? so that my model can read and my CJuidatePicker can use this value always 1970/01/01 (T.T)
thanks …