Last active
October 11, 2015 13:52
-
-
Save Doopin/7f0dbb3a965f66dc8b64 to your computer and use it in GitHub Desktop.
Csrf field validation always fails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//The form declaration Class | |
$this->add(array( | |
'type' => 'Csrf', | |
'name' => 'sec', | |
'options' => array( | |
'csrf_options' => array( | |
'timeout' => 600 | |
) | |
) | |
)); | |
?> | |
<!-- In the The form validator Class --> | |
<?php | |
$inputFilter->add($factory->createInput([ | |
'name' => 'sec', | |
'validators' => [ | |
[ | |
'name' => 'Csrf', | |
'options' => [ | |
'messages' => [ | |
Validator\Csrf::NOT_SAME => 'Csrf field is not valid' | |
] | |
] | |
] | |
], | |
])); | |
?> | |
<!-- In the view add.phtml --> | |
<?php | |
$addUserForm = $this->addUserForm; | |
$addUserForm->prepare(); | |
echo $this->form()->openTag($addUserForm); | |
echo $this->formHidden($addUserForm->get('sec')); | |
echo $this->formSubmit($addUserForm->get('submitButton')); | |
echo $this->form()->closeTag($addUserForm); | |
?> | |
<!-- But validation allways fails and I have the below error message --> | |
<!-- Take a look of the genarated html code for this field --> | |
<input type="hidden" value="c12c519e72c92b487aee6d927364efb9-42bb58b42345ec77c142c4d0b99db956" name="sec"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need help please