我有这样的表:
<tr>
<td style="width:5% !important;"><input type="text" style="width:50%" name="CostingSheet[CostingSheetCredits[][pax_adult]]" value="1"></td>
<td style="width:5% !important;"><input type="text" style="width:50%" name="CostingSheet[CostingSheetCredits[][pax_inf]]" value=""></td>
</tr>
当我提交它时,我会得到这样的数组:
["CostingSheetCredits["]=>
["pax_adult"]=> "2"
["pax_inf"]=> ""
我想要这样的东西:
["CostingSheetCredits]=>
[0] =>
["pax_adult"]=> "2"
["pax_inf"]=> ""
我做错了什么?这已经困扰了我好几天了。感谢大家的回答和帮助。
您需要这样的分组名称:
<input type="text" style="width:50%" name="CostingSheet[CostingSheetCredits][0][pax_adult]" value="1">
<input type="text" style="width:50%" name="CostingSheet[CostingSheetCredits][0][pax_inf]" value="2">
因此,它们将被视为同一个巢穴:
CostingSheet[CostingSheetCredits][0][pax_adult]
CostingSheet[CostingSheetCredits][0][pax_inf]
^ same row index
只需传递0或从更改名称
CostingSheet[CostingSheetCredits[][pax_adult]]
至
CostingSheet[CostingSheetCredits][0][pax_adult]
您需要对这两个字段进行更改。