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