00001 <?php
00002
00003
00004
00005
00006
00007
00008 class InputWidgetRadioBase extends InputWidgetBase {
00009
00010
00011
00012 protected function render_input($attrs, $params, $name, $title, $value, $policy) {
00013 $options = Arr::get_item($attrs, 'options', array());
00014 unset($attrs['options']);
00015
00016 $ret = '';
00017 $id = Arr::get_item($attrs, 'id', '');
00018 foreach(Arr::force($options, false) as $opt_key => $opt_value) {
00019 $attrs_copy = $attrs;
00020 $attrs_copy['value'] = $opt_key;
00021 if ($id) {
00022 $attrs_copy['id'] = $id . '_' . $opt_key;
00023 if ($opt_key == $value) {
00024 $attrs_copy['checked'] = 'checked';
00025 }
00026 }
00027 $radio_html = '';
00028 $radio_html .= html::input('radio', $name, $attrs_copy);
00029 $radio_html .= ' ' . String::escape($opt_value);
00030 $radio_html = html::label($radio_html, '', 'spanning');
00031 $ret .= $radio_html;
00032 }
00033 return $ret;
00034 }
00035
00036
00037
00038
00039 protected function render_label($widget, $html_attrs, $params, $name, $title, $value, $policy) {
00040 return parent::render_label($widget, $html_attrs, $params, $name, $title, $value, $policy | WidgetInput::NO_LABEL);
00041 }
00042 }