加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

yii2 ActiveForm数字文本字段

发布时间:2020-12-13 22:42:41 所属栏目:PHP教程 来源:网络整理
导读:我使用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' ])-te
我使用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)?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读