Today, Petr Vytlacil asked me how to create input fields with the html helper so that the values are in the same array, i.e. how to create something like:

<input name="data[Price][price][]” value= “” />
<input name=”data[Price][price][]” value= “” />

The obvious approach with

$html->inputTag('Price/price[]‘);

does not work, as it creates a wrong name:

<input  name="data[Price][price[]]” value=”" />

If we look at this output, we can see, how CakePHP works: it splits “Price/size[]” on the “/” character and adds square brackets. That leads us to the following workaround:

$html->inputTag('Price/price][');

Sure, it is a little bit counterintuitive, but it does the job ;-)