1: <?php
2: /**
3: * Pry Framework
4: *
5: * LICENSE
6: *
7: * This source file is subject to the new BSD license that is bundled
8: * with this package in the file LICENSE.txt.
9: *
10: * @version $Revision: 276 $
11: */
12:
13: /**
14: * Représentation des élément a choix multiple (select, radio)
15: * @category Pry
16: * @package Form
17: * @subpackage Form_Element
18: * @abstract
19: * @version 1.1.0
20: * @author Olivier ROGER <oroger.fr>
21: */
22: abstract class Form_Element_Multi extends Form_Field
23: {
24:
25: /**
26: * Liste des choix possible
27: *
28: * @var array
29: * @access protected
30: */
31: protected $choix;
32:
33: /**
34: * Constructeur
35: *
36: * @param string $nom
37: * @param Form_Form $form
38: * @access public
39: */
40: public function __construct($nom,$form)
41: {
42: parent::__construct($nom,$form);
43: $this->attrs['name'] = $nom;
44: }
45:
46: /**
47: * Enregistre les choix possibles
48: *
49: * @param array $choix La clé = valeur html du code html , la valeur = valeur afficher à l'utilisateur
50: * @access public
51: * @return Form_Element_Multi
52: */
53: public function choices(array $choix)
54: {
55: if(is_array($choix))
56: $this->choix = $choix;
57: else
58: throw new InvalidArgumentException('Le/les choix doivent être un array');
59: return $this;
60: }
61:
62: public function setAttributes($nom,$valeur)
63: {
64: if(!isset($this->attrs[$nom]))
65: $this->attrs[$nom] = $valeur;
66: }
67: }
68: ?>