Skip to content

Instantly share code, notes, and snippets.

@Doopin
Last active October 11, 2015 13:52
Show Gist options
  • Save Doopin/7f0dbb3a965f66dc8b64 to your computer and use it in GitHub Desktop.
Save Doopin/7f0dbb3a965f66dc8b64 to your computer and use it in GitHub Desktop.
Csrf field validation always fails
<?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">
@Doopin
Copy link
Author

Doopin commented Oct 11, 2015

Need help please

csrf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment