Hi Izo,
thx for your answer and please more help :-)
Ok now i have the problem, where i have to insert this code.
In Vokuro the forms will generate in 1 initialize() function and here is the CSRF implementaion:
<?php
namespace Vokuro\Forms;
use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Password;
use Phalcon\Forms\Element\Submit;
use Phalcon\Forms\Element\Check;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\Identical;
class LoginForm extends Form
{
public function initialize()
{
// Email
$email = new Text('email', [
'placeholder' => 'Email'
]);
$email->addValidators([
new PresenceOf([
'message' => 'The e-mail is required'
]),
new Email([
'message' => 'The e-mail is not valid'
])
]);
$this->add($email);
// Password
$password = new Password('password', [
'placeholder' => 'Password'
]);
$password->addValidator(new PresenceOf([
'message' => 'The password is required'
]));
$password->clear();
$this->add($password);
// Remember
$remember = new Check('remember', [
'value' => 'yes'
]);
$remember->setLabel('Remember me');
$this->add($remember);
// CSRF
$csrf = new Hidden('csrf');
$csrf->addValidator(new Identical([
'value' => $this->security->getSessionToken(),
'message' => 'CSRF validation failed'
]));
$csrf->clear();
$this->add($csrf);
$this->add(new Submit('go', [
'class' => 'btn btn-success'
]));
}
}
Now i have also to implement this workaround. Please can you give me a short trick to do that.
Rgds
Stefan