Operator1
Operator1

Reputation: 31

Symfony2 Forms - custom input names

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 - 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.

Upvotes: 1

Views: 2018

Answers (1)

Vince V.
Vince V.

Reputation: 3143

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);

Upvotes: 1

Related Questions