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

Readme example error #24

Open
Matt-PMCT opened this issue Jan 15, 2018 · 1 comment
Open

Readme example error #24

Matt-PMCT opened this issue Jan 15, 2018 · 1 comment

Comments

@Matt-PMCT
Copy link

Matt-PMCT commented Jan 15, 2018

If I use the readme example:


use \ParagonIE\AntiCSRF\AntiCSRF;
$twigEnv->addFunction(
    new \Twig_SimpleFunction(
        'form_token',
        function($lock_to = null) {
            static $csrf;
            if ($csrf === null) {
                $csrf = new AntiCSRF;
            }
            return $csrf->insertToken($lock_to, false);
        },
        ['is_safe' => ['html']]
    )
);

if put just this in my twig file

{{ form_csrf() }}

I get an error stating that $lock_to must be a string, not null. Not sure if this is intended or not, but if I define lock_to as '' it works since it is a string now.

-Matt

@Nenglish7
Copy link
Contributor

Nenglish7 commented Jan 26, 2018

What type of error is it, Type out the exact output. Make the parameter that you are passing in the form_token function is a string. I noticed you tried {{ form_csrf() }}, but in the documentation it says to use {{ form_token() }}. The string parameter needs to be a local path.

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

No branches or pull requests

2 participants