我使用yii2创建了一个ActiveForm,如下所示:
<?=$form->field($item,'finalPrice',[ 'options' => [ 'tag' => 'div','class' => '',],'template' => '<span class="col-md-2 col-lg-2"><label class="control-label">Final item price</label>{input}{error}</span>' ])->textInput([ // ** i want numeric value ** ])->label(false)?>
它产生了以下结果:
<span class="col-md-2 col-lg-2"><label class="control-label">Final item price</label><input type="text" id="item-finalprice" class="form-control" name="Item[finalPrice]"><p class="help-block help-block-error"></p></span>
现在我想做它<输入类型=“数字”..而不是文本..(因此用户可以使用浏览器向上/向下按钮更改值).有什么办法吗?
您可以使用 – > textInput([‘type’=>’number’]例如:
<?=$form->field($item,'template' => '<span class="col-md-2 col-lg-2"><label class="control-label">Final item price</label>{input}{error}</span>' ])->textInput([ 'type' => 'number' ])->label(false)?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。