【发布时间】:2012-11-06 19:52:59
【问题描述】:
我在 Symfony2 中使用表单生成器时遇到问题。 确切地说,我需要输入字段是 html 数组,但我无法使用 createFormBuilder->add 创建它。 这是我尝试过的:
$attributesForm = $this->createFormBuilder()
->add('attribute[0]', 'text') ...
等等,但我得到以下异常:
名称“attribute[0]”包含非法字符。名称应以字母、>数字或下划线开头,并且只能包含字母、数字、数字、下划线(“_”)、连字符 >(“-”)和冒号(“:”)。
有什么好的解决方案还是我必须手动创建字段?
提前致谢!
编辑:进一步澄清这一点...... 我想要生成这样的东西:
<div id="msoft_adminbundle_offertype">
<div>Name <input type="text" name="name"></div>
<div>...</div>
<div>Attribute 0 <input type="text" name="attribute[0]"></div>
<div>Attribute 1 <input type="text" name="attribute[1]"></div>
<div>Attribute 3 <input type="text" name="attribute[3]"></div>
<ul>
</ul>
<p>
<button type="submit">Edit</button>
</p>
帮助?
【问题讨论】:
标签: php symfony formbuilder