Created
September 27, 2012 08:54
-
-
Save bakura10/3792968 to your computer and use it in GitHub Desktop.
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 Common\Registry\Registry; | |
use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity as DoctrineHydrator; | |
use User\Entity\StudentSkill as StudentSkillEntity; | |
use Zend\Form\Fieldset; | |
use Zend\InputFilter\InputFilterProviderInterface; | |
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator; | |
class StudentSkill extends Fieldset implements InputFilterProviderInterface | |
{ | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->setHydrator(new DoctrineHydrator(Registry::get('EntityManager'))) | |
->setObject(new StudentSkillEntity()); | |
$this->add(array( | |
'name' => 'id', | |
'attributes' => array( | |
'type' => 'hidden' | |
) | |
)); | |
$this->add(array( | |
'name' => 'name', | |
'attributes' => array( | |
'type' => 'text', | |
'maxlength' => 32, | |
'style' => 'width: 44.8%' | |
) | |
)); | |
$this->add(array( | |
'type' => 'Zend\Form\Element\Select', | |
'name' => 'level', | |
'options' => array( | |
'value_options' => array( | |
25 => 'Débutant', | |
50 => 'Intermédiaire', | |
75 => 'Confirmé', | |
100 => 'Expert' | |
) | |
), | |
'attributes' => array( | |
'style' => 'width: 47%', | |
'value' => 25, | |
'class' => 'last' | |
) | |
)); | |
} | |
/** | |
* @return array | |
*/ | |
public function getInputFilterSpecification() | |
{ | |
return array( | |
'id' => array( | |
'required' => true, | |
'allow_empty' => true | |
), | |
'name' => array( | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StringTrim'), | |
array('name' => 'StripTags') | |
), | |
'validators' => array( | |
array( | |
'name' => 'StringLength', | |
'options' => array('max' => 32) | |
) | |
) | |
), | |
'level' => array( | |
'required' => true | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment