Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form events fire at the wrong time #4

Closed
EvanDotPro opened this issue Jan 13, 2012 · 2 comments
Closed

Form events fire at the wrong time #4

EvanDotPro opened this issue Jan 13, 2012 · 2 comments

Comments

@EvanDotPro
Copy link
Member

The captcha element for example, is added after the init event, so it cannot be overridden via listeners. This needs to be changed.

@danrossi
Copy link

My work around was to disable that config, and then add my own captcha element, but by all means ;)

This is what my module bootstrap listener callback looks like

public function initializeView($e)
{
    $app          = $e->getParam('application');
    $locator      = $app->getLocator();
    $config       = $e->getParam('config');
    $view         = $this->getView($app);
    $viewListener = $this->getViewListener($view, $config);
    $app->events()->attachAggregate($viewListener);
    $events       = StaticEventManager::getInstance();
    $viewListener->registerStaticListeners($events, $locator);


    $events->attach('ZfcUser\Form\Register', 'init', function($e) use ($config, $app) {
            $form = $app->getLocator()->get('custom_register_form');
            $form->init($e->getTarget(), $config);
    });

    $events->attach('ZfcUser\Form\Login', 'init', function($e) use ($config, $app) {
            $form = $app->getLocator()->get('custom_login_form');
            $form->init($e->getTarget(), $config);
    });

    $events->attach('ZfcUser\Service\User', 'createFromForm', function($e) use ($config, $app) {


            var_dump($e->getParams());

            exit;
    });

}

@EvanDotPro
Copy link
Member Author

I think this is resolved as of the new Zend\Form. We can re-open if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants