Danielss89 / ZfcUserAdmin

An admin interface for ZfcUser
36 stars 45 forks source link

Binding User to Edit Form fixes issues #30 and #31 #50

Open webdevilopers opened 10 years ago

webdevilopers commented 10 years ago

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

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 ?

webdevilopers commented 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

webdevilopers commented 10 years ago

I have added the zfcuser_user_hydrator inside the controllers actions.