Is it possible to make \Phalcon\Security available to \Phalcon\Form so as to aid in the generation of csrf hidden fields when extending the class.
class Login extends \Phalcon\Form
{
public function initialize()
{
// Identity Field.
$identity = new Text('identity');
$identity->addValidator(new Email(
array(
'message' => 'A valid email address is required.'
)
));
$identity->setLabel("Email Address.");
$this->add($identity);
// Password Field.
$password = new Password('passowrd');
$password->setLabel('Password');
$password->addValidator(new PresenceOf(
array(
'message' => 'You must provide a password.'
)
));
$this->add($password);
$csrf = new Hidden(array(
'name' => $this->security->getTokenKey(),
'value' => $this->security->getToken(),
'id' => 'xtoken'
));
$csrf->addValidator(new Csrfl(
array(
'message' => 'Tokens do not match.'
)
));
$this->add($csrf);
}
}