如何在 Yii 中更改时间选择器文本框的默认大小。我正在从链接时间选择器在 Yii 中使用时间选择器。
我已经尝试了html选项,它现在可以工作了,
$this->widget('application.extensions.timepicker.timepicker',
array(
'model'=>$model,
'name'=>'starttime',
'select'=> 'time',
'options' => array(
'showOn'=>'focus',
'timeFormat'=>'hh:mm:ss',
'htmlOptions' => array(
'size' => '10', // textField size
'maxlength' => '10', // textField maxlength
),
),
)
);
将 HTML 选项设置为时间选择器的正确方法是什么。
我认为您的htmlOptions
不应该在options
数组中。
我正在使用Yii扩展EJuiDateTimePicker(http://www.yiiframework.com/extension/ejuidatetimepicker/),它基本上基于相同的时间选择器,在那里我可以像这样定义文本字段大小:
$this->widget('ext.timepicker.EJuiDateTimePicker', array(
'model'=>new Report(),
'name'=>'creation_date',
'options' => array(
'showOn'=>'focus',
'timeFormat'=>'hh:mm:ss',
'timeOnly'=>true,
),
'htmlOptions' => array(
'style'=>'width:150px;', // styles to be applied
'maxlength' => '10', // textField maxlength
),
));
希望这有帮助...
修改时间选取器小组件视图文件。将有一个 size 属性。
<input type="text" class="timepicker" id="<?php echo $this->id; ?>" value="<?php echo $this->model->{$this->name}?$this->model->{$this->name}:$this->options['value']; ?>" name="<?php echo get_class($this->model).'['.$this->name.']'.$this->tabularLevel; ?>" size="15" />