简体   繁体   English

如何在codeigniter购物车中设置数量更新的最大值

[英]how to set max value in quantity update in codeigniter cart

<?php echo form_input('cart[' . $item['id'] . '][qty]', $item['qty'], max=> $item['price'] ' type="number"  min="1" value="1" )'; ?>

如何设置最大值它显示我语法错误,意外的“=>”(T_DOUBLE_ARROW)

Easiest way is to pass associative array,最简单的方法是传递关联数组,

<?php 
      echo form_input(
             array(
               'name'=> 'cart[' . $item['id'] . '][qty]', 
               'type'=>"number",
               'min'=>1,
               'max'=> $item['price'],
               'value'=> $item['qty'], 
              ) 
      ); 
?>

You still can correct your existing one like below您仍然可以像下面这样更正现有的

<?php 
    echo form_input(
              /*name*/
             'cart[' . $item['id'] . '][qty]',  

             /* value */
             $item['qty'],                       

             /* other attributes as string */
             'max="'.$item['price'].'" type="number" min="1"'           
     ); 
?>

From :https://www.codeigniter.com/userguide3/helpers/form_helper.html来自:https ://www.codeigniter.com/userguide3/helpers/form_helper.html

form_input([$data = ''[, $value = ''[, $extra = '']]])

Parameters:参数:

 $data (array) – Field attributes data $value (string) – Field value $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string

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

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