简体   繁体   English

Codeigniter:使用表单助手输入类型编号

[英]Codeigniter : Input type number using form helper

I am trying to set input type as number while using form helper.我试图在使用表单助手时将输入类型设置为数字。

Following is the code I tried but it did not work for me, Please help me with this.以下是我尝试过的代码,但它对我不起作用,请帮我解决这个问题。

<?php

 $numberfield = array( 'type' => 'number', 'class' => 'form-control qty ' );
 echo form_input('cart[' . $item['id'] . '][qty]', $item['qty'], 'maxlength="3" size="1" style="text-align: right"',$numberfield); ?>

Well you have the syntax wrong.那么你的语法错误。 You are giving it 4 parameters, while it only accepts at most 3. Those also don't really make sense.你给它 4 个参数,而它最多只接受 3 个。这些也没有意义。 Either use array or a string, but not both.使用数组或字符串,但不能同时使用。 According to PHP-rules it will simply ignore the 4th parameter (which is the one in which you specified the input's type)根据 PHP 规则,它会简单地忽略第四个参数(这是您指定输入类型的参数)

You can read the documentation here, it should make it clear, how to correctly use form_input . 您可以在这里阅读文档,它应该清楚说明如何正确使用form_input

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM