ZF-Commons / ZfcUser

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)
BSD 3-Clause "New" or "Revised" License
497 stars 343 forks source link

Form customization not working on lastest ZF3 version. #665

Open BnitoBzh opened 7 years ago

BnitoBzh commented 7 years ago

I am migrating my application from ZF2 to ZF3. All dependencies work as expected on ZF3 except ZfcUser with form customization by events ... In order to test in good conditions, i have tested this function in an empty new ZF3 project based on ZendSkeletonApplication. But nothing works as expected for the form customization feature.

The ZfcUser module version 2.* hasn't be updated from 7 months, Is there always maintained for ZF3 ?

stijnhau commented 7 years ago

Can you posy code example?

BnitoBzh commented 7 years ago

I am using wiki example. see https://github.com/ZF-Commons/ZfcUser/wiki/How-to-modify-the-form-objects-used-by-ZfcUser on bootstrap function, which is correctly executed.

$events = $e->getApplication()->getEventManager()->getSharedManager();

$events->attach('ZfcUser\Form\Register', 'init', function ($e) {
    $form = $e->getTarget();
    $form->add([
        'name' => 'test',
        'type' => 'Zend\Form\Element\Text',
        'attributes' => [
            'placeholder' => 'Test field'
        ]
    ]);
});

But there is no 'test' field displayed on register page. I think it's a problem with SharedManager and/or ProvidesEventsForm class due to the new version of zend framework.

olexp commented 7 years ago

Confirm that. Already pointed out the same issue in ZF3 compatibility https://github.com/ZF-Commons/ZfcUser/issues/642#issuecomment-246374938 The issue exists in released zf-commons/zfc-user 3.0.0.

snapshotpl commented 7 years ago

Confirm. Problem is that init method is called in constructor, where is not yet injected event-manager with sharedmanager... Prefer to use Delegator to fix that.

bartmcleod commented 6 years ago

I have struggled with this problem, and found it easier for my use case to work with the components in Zend\Authorization directly. You don't get all the bells and whistles that ZfcUser used to provide out of the box, but you also do not get the pain of customization.