Changeset 1503
- Timestamp:
- 12/12/2007 04:13:09 PM (13 months ago)
- Files:
-
- 1 modified
-
trunk/modules/forge/libraries/Form_Checklist.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/forge/libraries/Form_Checklist.php
r1502 r1503 5 5 protected $data = array 6 6 ( 7 'name' => '', 8 'type' => 'checkbox', 9 'class' => 'checklist', 7 'name' => '', 8 'type' => 'checkbox', 9 'class' => 'checklist', 10 'options' => array(), 10 11 ); 11 12 … … 22 23 { 23 24 // Return the currently checked values 24 return array_keys($this->data['options'], TRUE); 25 $array = array(); 26 foreach($this->data['options'] as $id => $opt) 27 { 28 // Return the options that are checked 29 ($opt[1] == TRUE) and $array[] = $id; 30 } 31 return $array; 25 32 } 26 33 … … 40 47 41 48 $checklist = '<ul class="'.arr::remove('class', $base_data).'">'.$nl; 42 foreach(arr::remove('options', $base_data) as $val => $ checked)49 foreach(arr::remove('options', $base_data) as $val => $opt) 43 50 { 44 51 // New set of input data 45 52 $data = $base_data; 53 54 // Get the title and checked status 55 list ($title, $checked) = $opt; 46 56 47 57 // Set the name, value, and checked status … … 49 59 $data['checked'] = $checked; 50 60 51 $checklist .= '<li><label>'.form::checkbox($data).' '.$ val.'</label></li>'.$nl;61 $checklist .= '<li><label>'.form::checkbox($data).' '.$title.'</label></li>'.$nl; 52 62 } 53 63 $checklist .= '</ul>'; … … 65 75 if (empty($_POST[$this->data['name']])) 66 76 { 67 $this->data['options'][$val] = FALSE;77 $this->data['options'][$val][1] = FALSE; 68 78 } 69 79 else 70 80 { 71 $this->data['options'][$val] = in_array($val, $_POST[$this->data['name']]);81 $this->data['options'][$val][1] = in_array($val, $_POST[$this->data['name']]); 72 82 } 73 83 }
