yii timepicker - 显示当前时间

时间:2014-10-26 12:05:39

标签: php yii timepicker

我正在使用yii timepicker扩展来显示时间。当我点击创建新的calllog时,我需要在文本字段中自动显示当前时间。我尝试获取该字段的当前时间但很难做到这一点。请任何人都可以帮助我解决了这个问题?

当我点击创建calllog时,我可以像这样显示

enter image description here

我需要看到这样的当前日期和时间

enter image description here

我的观看代码,

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'calllog-form',
    'enableAjaxValidation'=>false,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); ?>

    <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,'date'); ?>

        <?php $this->widget('application.extensions.timepicker.timepicker', array(
             'model'=>$model,
             'name'=>'date',
             'options'=>
                array(
                    'dateFormat'=>'dd-mm-yy'
                )           
           )); 


       ?>       
       <?php echo $form->error($model,'date'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'restaurant_id'); ?>
        <?php //echo $form->textField($model,'restaurant_id'); ?>
        <?php echo CHtml::activeDropDownList($model,'restaurant_id', $model->getRestaurant(),array('prompt' => '--Select Restaurant--')); ?>
        <?php echo $form->error($model,'restaurant_id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'contact_person'); ?>
        <?php echo $form->textField($model,'contact_person',array('size'=>60,'maxlength'=>255)); ?>
        <?php echo $form->error($model,'contact_person'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'phone'); ?>
        <?php echo $form->textField($model,'phone',array('size'=>60,'maxlength'=>100)); ?>
        <?php echo $form->error($model,'phone'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'feedback'); ?>
        <?php echo $form->textArea($model,'feedback',array('rows'=>6, 'cols'=>50)); ?>
        <?php echo $form->error($model,'feedback'); ?>
    </div>

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

value数组中传递option参数。这样的事情。

<?php $this->widget('application.extensions.timepicker.timepicker', array(
    'model'=>$model,
    'name'=>'date',
    'options'=>
        array(
            'dateFormat'=>'dd-mm-yy',
            'value'=>date('d-m-Y H:i:s'),
        ),
     )
 );