00001 <? 00008 class MultiSelectField extends SelectField 00009 { 00013 public function drawInput() 00014 { 00015 $attr = $this->extrasAsAttributes(); 00016 ?> 00017 <span> 00018 <div style="float: left; display: inline;"> 00019 <? 00020 echo "\t<select name=\"$this->name[]\" $attr>"; 00021 00022 foreach($this->options as $value => $title) 00023 { 00024 $selected = ''; 00025 if (is_array($this->value) && in_array($value, $this->value)) 00026 $selected = 'selected="selected"'; 00027 echo "<option value=\"$value\" $selected>$title</option>"; 00028 } 00029 ?> 00030 </select> 00031 </div> 00032 <div style="float: left; display: inline; margin-left: 10px; width: 300px;"> 00033 <p>Tip: By holding the '<b>Ctrl</b>' key and clicking on items, you 00034 can select multiple items.</p> 00035 00036 <p>You can also select large chunks of the list by 00037 holding '<b>Shift</b>' and clicking items.</p> 00038 </div> 00039 <br style="clear: both;"/> 00040 </span> 00041 <? 00042 } 00043 00044 public function getData() 00045 { 00046 return implode(",", $this->value); 00047 } 00048 00049 public function setData($value) 00050 { 00051 if (is_array($value)) 00052 $this->value = $value; 00053 else 00054 $this->value = array($value); 00055 } 00056 } 00057 ?>