Created
March 13, 2014 14:34
-
-
Save ricardofiorani/9529643 to your computer and use it in GitHub Desktop.
UserPasswordForm
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 | |
namespace User\Form; | |
use Doctrine\ORM\EntityManager; | |
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; | |
use User\Entity\User; | |
use Zend\Form\Form; | |
use Zend\InputFilter\InputFilterProviderInterface; | |
class UserPasswordForm extends Form implements InputFilterProviderInterface { | |
/** | |
* @var EntityManager | |
*/ | |
protected $entityManager; | |
public function getEntityManager() { | |
return $this->entityManager; | |
} | |
public function setEntityManager(EntityManager $entityManager) { | |
$this->entityManager = $entityManager; | |
} | |
public function init() { | |
$this->setAttribute('class', 'form-horizontal'); | |
$this->setAttribute('method', 'post'); | |
$this->add(array( | |
'type' => 'hidden', | |
'name' => 'id', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'Int'), | |
), | |
)); | |
$this->add(array( | |
'type' => 'csrf', | |
'name' => 'csrf' | |
)); | |
$this->add(array( | |
'name' => 'old_password', | |
'type' => 'password', | |
'attributes' => array( | |
'placeholder' => "Old Password", | |
'class' => 'form-control', | |
), | |
'options' => array( | |
'label' => "Old Password", | |
), | |
)); | |
$this->add(array( | |
'name' => 'new_password', | |
'type' => 'password', | |
'attributes' => array( | |
'placeholder' => "New Password", | |
'class' => 'form-control', | |
), | |
'options' => array( | |
'label' => "Password", | |
), | |
)); | |
$this->add(array( | |
'name' => 'new_password_confirm', | |
'type' => 'password', | |
'attributes' => array( | |
'placeholder' => "New Password (Confirm)", | |
'class' => 'form-control', | |
), | |
'options' => array( | |
'label' => "New Password (Confirm)", | |
), | |
)); | |
} | |
public function getInputFilterSpecification() { | |
return array( | |
'old_password' => array( | |
'required' => true, | |
'filters' => array( | |
array('password' => 'Zend\Form\Element\Password'), | |
), | |
), | |
'new_password' => array( | |
'required' => true, | |
'filters' => array( | |
array('password' => 'Zend\Form\Element\Password'), | |
), | |
), | |
'new_password_confirm' => array( | |
'required' => true, | |
'filters' => array( | |
array('password' => 'Zend\Form\Element\Password'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'Identitcal', | |
'options' => array( | |
'token' => 'new_password', | |
) | |
) | |
) | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/danizord/9529739/revisions