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

Loading wrong template #83

Open
radoslawkoziol opened this issue Apr 15, 2015 · 5 comments
Open

Loading wrong template #83

radoslawkoziol opened this issue Apr 15, 2015 · 5 comments

Comments

@radoslawkoziol
Copy link

Hi I found a problem,

Every register route loads wrong (default) tempate. I found that is caused by those lines in

RegistrationManager.php

    $result = $this->controller->registerAction($this->container->get('request'));
    if ($result instanceof RedirectResponse) {
        return $result;
    }

$this->controller->registerAction($this->container->get('request'));

This renders default register form and prevents to run this:

    $template = $this->userDiscriminator->getTemplate('registration');
    if (is_null($template)) {
        $engine = $this->container->getParameter('fos_user.template.engine');
        $template = 'FOSUserBundle:Registration:register.html.'.$engine;
    }

    $form = $this->formFactory->createForm();      
    return $this->container->get('templating')->renderResponse($template, array(
        'form' => $form->createView(),
    ));

That's because this in RegistrationController in FOSUserBundle
if (null !== $event->getResponse()) {
return $event->getResponse();
}

doesn't return null

When I delete wrong lines from RegistrationManager.php - everything works well.

Am I doing something wrong, or there is a bug?

Here is my config.yml

config.yml

pugx_multi_user:
  users:

    chiro:
        entity:
          class: Bos\UserBundle\Entity\Chiro
        registration:
          form:
            type: Bos\UserBundle\Form\RegistrationFormType
            name: bos_user_registration
            validation_groups:  [Registration, Default]
          template: BosUserBundle:Registration:register.html.twig

    patient:
        entity:
          class: Bos\UserBundle\Entity\Patient
        registration:
          template: BosUserBundle:Registration:register_patient.html.twig
          form:
            type: Bos\UserBundle\Form\RegistrationPatientFormType
            name: bos_user_registration_patient
@greg-man
Copy link

Same problem here, except when I remove the lines from RegistrationManager.php as you suggested, the form is not performed after submit. Instead it shows the empty registration form again.

Any ideas how to fix this?

@greg-man
Copy link

Well, found a solution by myself => need to check the request object for POST method, like so:

RegistrationManager.php (starting line 65)

$request = $this->container->get('request');
    if ($request->getMethod() == 'POST') {
        $result = $this->controller->registerAction($request);
        if ($result instanceof RedirectResponse) {
            return $result;
        }
    }

Maybe some official could check this issue (wether this is really a bug or OP and I are doing something wrong) and commit the suggested change?

@leopro
Copy link
Member

leopro commented May 28, 2015

@greg-man could you open a PR with the fix and a test to cover it?

@greg-man
Copy link

Too bad, as I dug further I found that the fix won't cover the problem fully. It still exists, when a form is submitted, but rejected for some constraints, e.g. duplicate email. Any ideas?

@greg-man
Copy link

Weird, don't know why, but custom templates are working now as expected. Must have done something wrong, doesn't seem to be a bug at all.

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

No branches or pull requests

3 participants