1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
class Backend_Form_Role extends App_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setMethod('post')
->setAttrib('id', 'backendform1');
$id_role = new Zend_Form_Element_Hidden('id_role');
$nom_role = New App_Form_Element_Text('nom_role');
$nom_role->setLabel('Nom du role')
->setAttrib('id','nom_role')
->setAttrib('size','150');
$id_parent = New Zend_Form_Element_Select('id_parent');
$id_parent->setLabel('Hérite de :')
->setAttrib('id','id_parent')
->setAttrib('style','width:150px;margin:0 0 15px 0');
$granted = New Zend_Form_Element_Select('granted');
$granted->setLabel('Granted')
->setAttrib('id','granted')
->setAttrib('style','width:75px;margin:0 0 15px 0')
->addMultiOption(0, 'Non')
->addMultiOption(1, 'Oui');
$submit = new App_Form_Element_Submit('Valider');
$submit->setAttrib('id', 'send')
->addDecorator('HtmlTag', array('tag' => 'p', 'id' => 'submit-wrap'));
$element = array(
$id_role,
$nom_role,
$id_parent,
$granted,
$submit
);
$this->addElements($element);
}
protected function _modifyElements($values)
{
$id_parent = New Zend_Form_Element_Select('id_parent');
$id_parent->setLabel('Hérite de :')
->setAttrib('id','id_parent')
->setAttrib('style','width:150px;margin:0 0 15px 0')
->addMultiOption(0, 'Sélectionner');
$roleMapper = new Backend_Model_RoleMapper();
$arrListeRoles = $roleMapper->fetchAllWithExclude($values['id_role'],true);
$countListeRoles = count($arrListeRoles);
if($countListeRoles){
for($i=0;$i<$countListeRoles;$i++){
$id_parent->addMultiOption($arrListeRoles[$i]['id_role'], $arrListeRoles[$i]['nom_role']);
}
}
//$_valeurs = $id_parent->getAttribs();
//$valeurs = $_valeurs['options'];
return $id_parent;
}
public function populate(array $values)
{
$values = $this->_modifyElements($values);
return parent::populate($values);
}
} |
Partager