15

次のように 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>

今、私はそれを < input type="number" .. ではなく text .. にしたいです(ユーザーはブラウザの上下ボタンを使用して値を変更できます)。それを行う方法はありますか?

4

4 に答える 4

46

->textInput(['type' => 'number']たとえば、次のように使用できます。

<?=$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([
                                 'type' => 'number'
                            ])->label(false)?>
于 2015-11-09T12:51:42.967 に答える