Reading around and playing with what I’ve got, I’ve concluded that I’m on the right path simply embedding the form(s) like any other:
$builder->add('user', 'fos_user_registration', array(
'label' => 'Sign up',
'error_bubbling' => false
));
And I’ve been theorising that I’d have to align my validation groups with those of FOSUser?:
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'ACME\ReviewBundle\Entity\Review',
'flowStep' => 1,
'validation_groups' => array('Registration', 'Profile')
));
}
Perhaps with Default too?:
'validation_groups' => array('Default', 'Registration', 'Profile')
However, the validation is still passing and it falls over at database level, so I’m guessing I need to do something else to assign the validation groups?
Beyond that, I’m also unsure how the processing of this is going to work, I could rip a load of it out of the FOSUser form handler and controller, but this seems a bit wet, and I’m wondering whether there is a better way? It would be nice to have it all reliant on the same logic.
To give some context, I’m using CraueFormFlow and I have a process a user needs to be able to start either authed or not. If they are unauthed, the a later step in the process needs them to either register or login.
I need to retain the data collected prior to authentication, which as far as I see, if I can embed the registration and login forms within my main form, should happen naturally.
Note: I have email confirmation off, so that isn’t a concern, and it should be possible to make the entire process linear, with the user coming out authenticated and having had their review submitted.
Turns out that I needed an
@Assertannotation, otherwise the validation isn’t applied.