Hi guys,
I am trying to implement CSRF protection to all of my forms, but I cannot seem to be able to make it work. This is how I declare my field in my form:
$csrf = new Hidden('csrf');
$csrf->addValidator(new Identical(array(
'value' => $this->security->getSessionToken(),
'message' => 'CSRF validation failed'
)));
$csrf->clear();
$this->add($csrf);
And this is how I am rendering it in the view:
{{ form.render('csrf', ['value': security.getToken()]) }}
And I am using
$this->request->isPost() && $this->security->checkToken()
to make sure I am getting a proper call. However, I cannot seem to be able to save a record (using this in a create action), but I am not getting any error messages either....
Any ideas?