简体   繁体   中英

Using an array as a input name in cakephp form helper

I am trying to categorise checkboxes with category|productname values. I need to use the cakephp form helper so I am somewhat clueless as to how to do that. I tried to use an array as the input name, but I am getting a lot of errors:

 // Current code:
 $this->Form->input(array("catname","prodname"),array(....)

 // Expected for html:
 <input name="data[formname][catname][prodname]" ... ">

Any ideas on how to do this?

您可以使用:

$this->Form->input('formname.catname.prodname', ...);

I am trying the same, I just figured out that you can print arrays with helpers this way

// Current code:
 $this->Form->input('Model.0.object');

For example, if you have 10 objects related to this model, that will print the first one, same for 1, 2 etc.

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