CaptchaBundle icon indicating copy to clipboard operation
CaptchaBundle copied to clipboard

Symfony (6.* and 7.*) complains about missing "You have requested a non-existent parameter "twig.form.resources"

Open saoco opened this issue 1 year ago • 2 comments

Hi all,

I was trying to use this great bundle with my Symfony application. Unfortunately, my installation complains that there is no parameter called "twig.form.resources", which is requested in line 41 of DependencyInjection/GregwarCaptchaExtension.php

/** @var array<string> $resources */
$resources = $container->getParameter('twig.form.resources');
$container->setParameter('twig.form.resources', array_merge(array('@GregwarCaptcha/captcha.html.twig'), $resources));

According to Twig's configuration guide there is only a configuration parameter form_themes.

So I forked this repository, removed the lines:

$resources = $container->getParameter('twig.form.resources');
$container->setParameter('twig.form.resources', array_merge(array('@GregwarCaptcha/captcha.html.twig'), $resources));

and added "@GregwarCaptcha/captcha.html.twig" to my twig configuration as additional form_theme:

twig:
    default_path: '%kernel.project_dir%/templates'
    paths:
        'assets/images': images
        'assets/css': styles
    debug: '%kernel.debug%'
    exception_controller: null
    form_themes:
        - 'bootstrap_3_horizontal_layout.html.twig'
        - 'Form/fields.html.twig'
        - '@SonataForm/Form/datepicker.html.twig'
        - '@FOSCKEditor/Form/ckeditor_widget.html.twig'
        - '@GregwarCaptcha/captcha.html.twig'
    globals:
        paypal_client_id: '%app.paypal_api_client_id%'
    file_name_pattern: '*.twig'

Once done, everything works as expected.

Now I am wondering, if I am the only one having this isssue or if this is a general problem?

Any help would be appreciated.

Best

Christian

saoco avatar Aug 27 '24 20:08 saoco

Same issue here

sylvaindeloux avatar Jan 12 '25 18:01 sylvaindeloux

You can fix it by putting Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true], at the end of your bundles.php file, so the twig.form.resources will exist.

sylvaindeloux avatar Jan 13 '25 08:01 sylvaindeloux