-
-
Save weaverryan/e8a6d3c3a9ecf2b6d46e937e8dd98ec4 to your computer and use it in GitHub Desktop.
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 | |
class MyController | |
{ | |
public function someAction() | |
{ | |
$form = $this->createForm(MyCustomFormType::class, $someEntityOrNull, [ | |
'entity_user_option' => 'some_value', | |
]); | |
$form2 = $this->createForm(MyCustomFormType::class, $someEntityOrNull, [ | |
'entity_user_option' => 'some_other_value', | |
]); | |
} | |
} |
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 | |
// ... | |
clas MyCustomFromType extends AbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
// fetch the option here and use it to do different things in your form | |
$entityUserOption = $options['entity_user_option']; | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
// this makes it legal to have this option | |
$resolver->setRequired(['entity_user_option']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment