Ejemplo n.º 1
0
 public static function radio($name, $availableValues = array(), $value = null, $label = null, $htmlAttributes = array(), $errors = array())
 {
     $itemData = array();
     $itemData['name'] = $name;
     $itemData['value'] = $value;
     $itemData['label'] = $label;
     $itemData['errors'] = $errors;
     $itemData = array_merge($itemData, $htmlAttributes);
     $item = new FormItem($itemData);
     $output = $item->renderLabel();
     $output .= '<div class="radio-list">' . "\n";
     foreach ($availableValues as $currentValue => $currentLabel) {
         $htmlAttributes = array('id' => $name . '-' . $currentValue);
         if ($currentValue == $value) {
             $htmlAttributes['checked'] = 'checked';
         }
         $output .= '<div class="radio-item">' . FormItem::input('radio', $name, $currentValue, $currentLabel, $htmlAttributes) . '</div>' . "\n";
     }
     $output .= '</div>' . "\n";
     return $output;
 }