-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Override Registration Controller #2837
Comments
App\Controller\RegistrationController: Change services.yaml |
Well, why are you trying to define your own form facotry services if you override the controller ? |
In Symfony 4 I have such error, when i try to overwrite the register controller: Cannot autowire service "App\Controller\RegisterController": argument "$formFactory" of method "__construct()" references interface "FOS\UserBundle\Form\Factory\FactoryInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "fos_user.profile.form.factory", "fos_user.registration.form.factory", "fos_user.change_password.form.factory", "fos_user.resetting.form.factory". |
Hi @si4kar, i defined the controller in services.yaml but my function not working.. (I use symfony 4.2) App\Controller\RegistrationController:
arguments:
$formFactory: '@fos_user.registration.form.factory' <?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
use FOS\UserBundle\Event\GetResponseUserEvent;
use Symfony\Component\HttpFoundation\Request;
class RegistrationController extends BaseController
{
public function registerAction(Request $request)
{
dd('oko');
}
} Have you an idea ? Thanks |
Symfony 4.2 uses DI. You should be able to define all the interfaces/factories in your controller _construct().. add them to the use clauses. Should just work if you have autowiring set to true. I just had to do this with our legacy app. You have to do some work in 3.4... YMMV services.yml
In your controller.
|
Hi, I've the same problem than @si4kar in symfony 4.4. How I can override registrationController? |
Hi @joseadame and @si4kar , # app/config/services.yaml
fos_user.registration.controller:
class: App\Application\UserBundle\Controller\RegistrationController
FOS\UserBundle\Form\Factory\FactoryInterface: '@fos_user.registration.form.factory' (Source: Using Aliases to Enable Autowiring) |
Hello,
I tried to override the registration controller for adding some custom fields, like register date.
But I have some problems:
app/config/services.yaml:
app/config/routes.yaml:
app/Controller/RegistrationController:
Thank you in advance :)
The text was updated successfully, but these errors were encountered: