User not activated when using RegisterFormBuilder in Multiple Form
Created 6 years ago by kiltedupHi, I have created a MultipleFormBuilder that uses the RegisterFormBuilder alongside a couple of other custom forms. Everything works with the exception of the User being activated once created. Activation mode is set to Automatic, and if I use the RegisterFormBuilder standalone, then the created user is activated. Is there anything that needs to be added to the Multiple form to activate the user? Cheers, Dave
Interesting.. I feel like the handler should still get hit..
May have misread this but are you saying the Handler of the form that is added does not get hit, but a different child form handler is used - with the $form->save()
The form is saved its just that its not activated and login doesn't happen - that would make sense I guess if it's a child form handler that is run - no authenticator or activator.
I've worked around it by throwing the activator and authenticator on into my on('save_user')
Ya that's a perfect workaround - but I was saying that the handler SHOULD be run I think from multi's for this very reason. So I will patch that later today after looking at the potential side effects more thoroughly. assume tomorrow you won't have to work around it.
So after some research the handler SHOULD be being hit. Cause it's post()
method is being ran which runs the handlers. I tested to confirm as well.
So my assumption is that you have extended the RegisterFormBuilder
with your own and something to keep in mind is that:
automatically detected component handlers will not work if the class is overridden
This is because by binding your own - you essentially change the location of the class and the handlers are no longer next to it and can not be detected. So for the handler - you would need to set that property on your class explicitly.
protected $handler = RegisterFormHandler::class;
Give that a shot I think you'll find it's all working as expected.
Hey - sorry. Got sidetracked and been away.
Thanks for looking into this. I'm stumped. Haven't extended the RegisterFormBuilder
- simply using it as it is.
This is my test code : all works - user is created along side the other two form entries (my own stuff). Just not getting the new user activated or logged in - with the dd
you suggested not being hit ???
SignupFormBuilder is a MultipleForm.
use Anomaly\UsersModule\User\Register\RegisterFormBuilder;
public function signup(
SignupFormBuilder $form,
RegisterFormBuilder $userForm,
ProfileFormBuilder $profileForm,
AccountFormBuilder $accountForm
){
$form->addForm('user', $userForm);
$profileForm->setSkips(['user']);
$form->addForm('profile', $profileForm);
$accountForm->setSkips(['user','plan']);
$form->addForm('account', $accountForm);
$form->on('saved_user', function() use ($form) {
$user = $form->getChildFormEntry('user');
$profile = $form->getChildFormEntry('profile');
$profile->user = $user;
$account = $form->getChildFormEntry('account');
$account->user = $user;
});
return $form->render();
}
@ryanthompson I am trying to do the same thing and I have the handler being hit, but
if (!$builder->canSave()) {
return;
}
always fails with no reason as to why, so the form just redirects back to a blank form. What would be the best way to troubleshoot this? If I don't use the handler and just save the form, it saves fine, but obvs doesn't do the activator as the handler does.
Try dumping the $builder->getFormErrors()
that should tell you what's up.
If you
dd('Test');
right here: https://github.com/anomalylabs/users-module/blob/2.3/src/User/Register/Command/HandleAutomaticRegistration.php#L51Does it get hit?