如何在yii中使用和禁用timepicker小时和分钟?

时间:2013-07-16 12:25:51

标签: frameworks yii timepicker

我如何在yii框架中使用它?
我想使用这个http://www.innovativecounseling.com/Templates/timesheet_includes/jquery-ui-timepicker-0.1.3/时间戳,并在几小时和几分钟内停用。

$('#timepicker').timepicker({
    showPeriod: true,
    onHourShow: OnHourShowCallback,
    onMinuteShow: OnMinuteShowCallback
});
function OnHourShowCallback(hour) {
  if ((hour > 22) || (hour < 6)) {
    return false; // not valid
}
return true; // valid
}
function OnMinuteShowCallback(hour, minute) {
  if ((hour == 22) && (minute >= 30)) { return false; } // not valid
  if ((hour == 6) && (minute < 30)) { return false; }   // not valid
  return true;  // valid
}

我在我的项目中使用这样的但是如何将其修改为我的timepicker。

这是我在_form.php页面上的datepicker和timepicker ...

<div class="row">
    <div class="tarih tarih2">
        <?php echo $form->labelEx($model,'tarih2'); ?>
        <?php
            $this->widget('zii.widgets.jui.CJuiDatePicker', array(
            'model' => $model,
            'attribute' => 'tarih2',
            'language' => 'tr',
            'options' => array(     
                'dateFormat' => 'dd-mm-yy',
                'size' => '10',         // textField size
                'maxlength' => '10',    // textField maxlength
                'minDate'=> date('d-m-Y', strtotime(Yii::app()->db->createCommand('select gidis_saat from tbl_takip where id="'. $model->id .'"')->queryScalar())),
            ),
            ));
        ?>
        <?php //echo $form->textField($model,'tarih'); ?>
        <?php echo $form->error($model,'tarih2'); ?>
    </div>

    <div class="tarih">
        <?php echo $form->labelEx($model,'donus_saat'); ?>
        <?php
            $this->widget('application.extensions.jui_timepicker.JTimePicker', array(
            'model'=>$model,
            'attribute'=>'donus_saat',
            // additional javascript options for the date picker plugin
            'options'=>array(
                //'showPeriod'=>true,  // Bu 12 - 24 saat arasında geçiş sağlıyor.
                'showPeriodLabels' => false,
                'showNowButton'=>true,
                'hourText' => 'Saat',
                'minuteText' => 'Dakika',
                'hours'=>array('starts'=>0, 'ends'=>23),
                'minutes'=>array('starts'=>0, 'ends'=>55, 'interval'=>5),
                ),
            'htmlOptions'=>array('size'=>8,'maxlength'=>8 ),
            ));
        ?>  
        <?php // echo $form->textField($model,'donus_saat'); ?>
        <?php echo $form->error($model,'donus_saat'); ?>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

使用为时间选择器提供的扩展程序通过此帖子Yii Timepicker