Open webdevilopers opened 10 years ago
I just recognized that this required the zfcuser_user_hydrator
to be set / used.
class Module // forminterface is automatically implemented?
{
public function onBootstrap(MvcEvent $e)
{
$em = $eventManager->getSharedManager();
$em->attach(
'ZfcUserAdmin\Form\EditUser',
'init',
function($e)
{
/* @var $form \ZfcUser\Form\Register */
$form = $e->getTarget();
$sm = $form->getServiceManager();
$om = $sm->get('Doctrine\ORM\EntityManager');
$form->setHydrator($sm->get('zfcuser_user_hydrator'));
}
);
}
}
I think this can be achieved by setting the hydrator inside the controller the way it currently happens: https://github.com/Danielss89/ZfcUserAdmin/blob/master/src/ZfcUserAdmin/Controller/UserAdminController.php#L50
I have added the zfcuser_user_hydrator
inside the controllers actions.
These changes are just a proposal for solution for the following issues:
I have not edited further code since I can't tell yet what consequences this will have on
EditUser
FormsetUser
event see https://github.com/Danielss89/ZfcUserAdmin/blob/master/src/ZfcUserAdmin/Form/EditUser.php#L72-76EditUser
FormpopulateFromUser()
method see https://github.com/Danielss89/ZfcUserAdmin/blob/master/src/ZfcUserAdmin/Form/EditUser.php#L83-99 and others.But - similar to binding the
User
to theCreateUser
Form inside thecreateAction
method, this scenario works with Doctrine's ORM withOneToOne
andManyToMany
relationships.Any thoughts, @Danielss89 ?