1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29:
30: class ListMultiple extends AbstractMultipleChoice
31: {
32: private $rows;
33: public function __construct($id, $choices, $rows = 5, ChoiceRenderer $choiceRenderer = null, Model $model = null)
34: {
35: parent::__construct($id, $choices, $choiceRenderer, $model);
36: $this->rows = $rows;
37: }
38:
39: protected function validateModel()
40: {
41: $object = $this->getModelObject();
42: if($object!=null && !is_array($object))
43: {
44: throw new \IllegalStateException('ListMultiple must have an array model');
45: }
46: }
47:
48: protected function onComponentTag(ComponentTag $tag)
49: {
50: $this->checkComponentTag($tag, 'select');
51: $this->checkComponentTagAttribute($tag, "multiple", "multiple");
52: $tag->put('size', $this->rows);
53: parent::onComponentTag($tag);
54: }
55:
56: protected function onComponentTagBody(ComponentTag $tag)
57: {
58: $this->renderOptions();
59: }
60:
61: protected function convertInput()
62: {
63: $selection = array();
64: foreach($this->getChoices() as $index => $choice)
65: {
66: foreach($this->getRawInputArray() as $value)
67: {
68: if($this->valueForChoice($choice, $value, $index))
69: {
70: array_push($selection, $choice);
71: }
72: }
73: }
74: $this->setConvertedInput($selection);
75: }
76: }
77:
78: ?>
79: