mauzilla
mauzilla

Reputation: 3592

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?

Upvotes: 0

Views: 3368

Answers (2)

Matheus
Matheus

Reputation: 920

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.

Upvotes: 0

dhofstet
dhofstet

Reputation: 9964

You can use:

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

Upvotes: 4

Related Questions