excelwebzone / EWZRecaptchaBundle

This bundle provides easy reCAPTCHA form field for Symfony.
MIT License
396 stars 160 forks source link

Silex : Could not load type "ewz_recaptcha" #95

Open sunil-silumala opened 8 years ago

sunil-silumala commented 8 years ago

after following all the steps , i am still not able to enable captcha. getting and error. InvalidArgumentException in FormRegistry.php line 92: Could not load type "ewz_recaptcha"

below are the silex and recaptcha-bundle verison in composer.json "silex/silex" : "~1.1", "excelwebzone/recaptcha-bundle": "dev-master"

mablae commented 8 years ago

The bundle does not register an form type name via ->getName() anymore since Symfony switched to FQCN instead.

I dont know how silex is supposed to work around or adapt this change. Could you share the code of your Form?

D-Bennett commented 8 years ago

I had a similar issue,

I fixed it by adding the following in the vendor files

EWZRecaptchaType.php

public function getName()
{
        return 'ewz_recaptcha';
}

RecaptchaExtension.php

public function getExtendedType()
{
  return FormType::class;
}

I had to adjust the RecaptchaServiceProvider.php as it was causing a conflict with the profiler

        // add loader for EWZ Template
        if (isset($app['twig'])) {
            $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
                $path = dirname(__FILE__).'/../Resources/views/Form';
                $loader->addPath($path);
                return $loader;
            }));
            $app['twig.form.templates'] = array_merge(
                $app['twig.form.templates'],
                array('ewz_recaptcha_widget.html.twig')
            );
        }

I hope this helps :)