Skip to content

Instantly share code, notes, and snippets.

@weaverryan weaverryan/MyController.php Secret
Created Jan 17, 2018

Embed
What would you like to do?
<?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',
]);
}
}
<?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
You can’t perform that action at this time.