0

I am stuck with a piece of code that i can't resolve.

I have an Entity, having some arguments. One of them is an Array.

I would like to display it in a Form as several <select> tags.

For instance, my array is called param and $param = array (a,b,c), i would like to get a html form like

 <select name='param[0]'>
      <option value='0'>0</option>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>
    <select name='param[1]'>
      <option value='0'>0</option>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>
    <select name='param[2]'>
      <option value='0'>0</option>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>

Then, at the from subsmission, i would like the $param array to be inserted in the database as an array.

I have try to use de Collection type, but i couldn't resolve it. Thanks for your help !

4

1 回答 1

0

我认为使用 3 列而不是数组会更好。

这样,您将每个选择元素的值存储在单独的列中。

于 2013-07-20T17:55:36.020 回答