/** * Add a row of radiobuttons to the form * @param string $name The HTML name (and #id) of the input field * @param string $title The text written next to the input field * @param string[][] $options An array of options, each of which is an array of value and title * @param string $selected The value of the selected radiobutton * @param HtmlElement $container (optional) The "container" to add it to **/ public function AddRadioButtons($name, $title, $options, $selected = null, $container = null) { $group = new HtmlElement('div', array('class' => 'formgroup')); $option_value = EMPTYSTRING; $option_title = EMPTYSTRING; foreach ($options as $option) { if (_array::IsLongerThan($option, 1)) { $option_value = $option[0]; $option_title = $option[1]; } else { $option_value = $option_title = $option; } $args = new HtmlAttributes(); $args->Add('type', 'radio'); $args->Add('class', 'radiobox'); $args->Add('name', $name); $args->Add('id', $name); $args->Add('value', $option_value); if ($selected == $option_value) { $args->Add('checked', true); } $group->AddChild(new HtmlElement('input', $args)); $group->AddChild(new HtmlElement('span', EMPTYSTRING, $option_title)); } $field = new HtmlElement('div', array('class' => 'formline')); $field->AddChild(new HtmlElement('label', array('for' => $name), $title)); $field->AddChild($group); $this->AddToContainer($field, $container); }