ZfcUserAdmin
ZfcUserAdmin copied to clipboard
Binding User to Edit Form fixes issues #30 and #31
These changes are just a proposal for solution for the following issues:
- https://github.com/Danielss89/ZfcUserAdmin/issues/30
- https://github.com/Danielss89/ZfcUserAdmin/issues/31
I have not edited further code since I can't tell yet what consequences this will have on
- custom form elements
EditUserFormsetUserevent see https://github.com/Danielss89/ZfcUserAdmin/blob/master/src/ZfcUserAdmin/Form/EditUser.php#L72-76EditUserFormpopulateFromUser()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 the CreateUser Form inside the createAction method,
this scenario works with Doctrine's ORM with OneToOne and ManyToMany relationships.
Any thoughts, @Danielss89 ?
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.