Created
March 28, 2011 12:58
-
-
Save weaverryan/890407 to your computer and use it in GitHub Desktop.
A proposed change to the new form factory's builder creation (to make easier)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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') | |
); |
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
The first alternative makes a lot of sense to me!