简体   繁体   中英

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. 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)

You can read the documentation here, it should make it clear, how to correctly use form_input .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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