Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A proposed change to the new form factory's builder creation (to make easier)
<?php
// current
$form = $this->get('form.factory')->create(
new ProductType(),
'my_form',
array('csrf_protection' => false, 'data_class' => 'Acme\StoreBundle\Entity\Product')
);
$product = new Product();
$form->setData($product);
====================
// proposed
$product = new Product();
$form = $this->get('form.factory')->create(
new ProductType(),
'my_form',
array('csrf_protection' => false, 'data' => $product)
);
=====================
// or even!
$product = new Product();
$form = $this->get('form.factory')->create(
new ProductType(),
$product,
array('csrf_protection' => false, 'name' => 'my_form')
);
@marijn

This comment has been minimized.

Copy link

commented Mar 28, 2011

The first alternative makes a lot of sense to me!

@inanimatt

This comment has been minimized.

Copy link

commented Mar 28, 2011

I like the first alternative too - it looks like it'd be compatible with the current method, too (create() would only have to call setData())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.