public function test_radio_button_tag() { $actual = FormTagHelper::radio_button_tag('passed', 'Yes'); $matcher = array('tag' => 'input', 'attributes' => array('type' => 'radio', 'name' => 'passed', 'id' => 'passed_Yes', 'value' => 'Yes', 'checked' => null)); $this->assertTag($matcher, $actual, 'Default attributes'); $actual = FormTagHelper::radio_button_tag('passed', 'yes', true); $this->assertRegexp('/checked="checked"/', $actual, "Checked radio button"); $actual = FormTagHelper::radio_button_tag('foo', 'bar', false, array('class' => 'blah')); $this->assertRegexp('/class="blah"/', $actual, "Additional attributes"); }
public function radio_button($name, $tag_value, $html_attributes = array()) { $value = strval($this->get_model_data($name)); $checked = $value == $tag_value; return FormTagHelper::radio_button_tag($this->get_field_name($name), $tag_value, $checked, $html_attributes); }