0

First of all I'm a bit of a noobie when it comes to Symfony2. I was wondering if anyone had any examples of using the Invitation functionality suggested in the FOSUserBundle cookbook.

I have followed the instructions to the letter, and I have added an invitation record via data fixtures. I'm running Symfony 2.3.7 and FOSUserBundle 2.0@dev

When I come to registering a user with the generated invite code, I get the error explained in the following: Symfony2 FOSUserBundle Invitation : only work on owning side associations which I've updated my reverseTransform method as per Shawn Northrop's suggestion. What I get now, when I register is that it returns to my register page with no errors, and no user has been added. If I swap the inversedBy and mappedBy association's it does the same.

FOSUserBundle is setup correctly, with all the routing as per defaults. So I wanted to take a step back and see if anyone can share how they have implemented the actual Invitation. When I load an invite via data fixtures, I do the following:

/* DataFixtures: load(ObjectManager $manager) method */
$invite1 = new Invitation();
$invite1->setEmail('email@example.com');
$invite1->send();
$manager->persist($invite1);
$manager->flush();

This generates a code, adds the email, and sets sent to true. Should I be adding anything to the User object at this point, or should this actually automatically do this via the mapping? Checking the User table after this runs (successfully), I see nothing there.

Really struggling to get my head round this as there is very sparse documentation around for it.

UPDATE I overrode the RegistrationController to try and debug. Seems to be falling down on the $form->isValid() check.

Hope someone can advise.

Community
  • 1
  • 1
Paul Pounder
  • 244
  • 1
  • 5
  • 14

1 Answers1

0

Ok, schoolboy error.

So I did:

die($form->getErrorsAsString());

Only to find out that there was no CSRF. Added:

{{ form_widget(form._token) }}

to my registration form, and all is good.

Paul Pounder
  • 244
  • 1
  • 5
  • 14