Last active
February 22, 2016 17:07
-
-
Save ABM-Dan/c3692a8e08094612f25f to your computer and use it in GitHub Desktop.
Embedded Form shenanigans
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 | |
// in the controller | |
$user->addCreditCard(new CreditCard()); | |
// this actually shows up in the form. | |
$user->getCreditCards()[0]->setCvv(123); | |
// in the outer form type | |
$builder->add( | |
'credit_card', | |
CollectionType::class, | |
[ | |
'type' => CreditCardType::class, | |
'property_path' => 'creditCards', | |
'entry_options' => [ | |
//'validation_groups' => ['credit_card'], | |
'container' => $container, | |
// this is just me being desperate | |
'constraints' => [new Assert\Valid(), new Assert\NotBlank()], | |
], | |
] | |
) | |
// Inner form type | |
// This is extra, just to test if the failure happens at entity level. But this check is ignored. | |
$builder->add('number', TextType::class, ['constraints' => [new Assert\NotBlank()]]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment