开发者

Symfony2 Forms - custom input names

开发者 https://www.devze.com 2023-03-31 06:00 出处:网络
I use Symfony2 form generation in a common way. $form = $this->createForm(new ValueType(), $entity);

I use Symfony2 form generation in a common way.

$form = $this->createForm(new ValueType(), $entity);
$view = $form->createView();

This renders form like

<input name="test_commonbundle_valuetype[value]" ...

How to make it to generate custom names开发者_如何学JAVA - like

<input name="test_commonbundle_sometype[values][N][value]"

?

I need it as i manually render entity template for parent object w/ajax processing - so getting child object and form.values does not suit for me.


In your form type you can add the property_path => false option to add a field to the form without being used by the entity.

$builder->add('myFancyName','text',array('property_path' => false);
0

精彩评论

暂无评论...
验证码 换一张
取 消