public function text_field($name, $html_attributes = array()) { $value = strval($this->get_model_data($name)); return FormTagHelper::text_field_tag($this->get_field_name($name), $value, $html_attributes); }
public function test_options_for_select_from_collection_with_objects() { $obj1 = new \StdClass(); $obj1->id = 1; $obj1->name = 'one'; $obj2 = new \StdClass(); $obj2->id = 2; $obj2->name = 'two'; $obj_data = array($obj1, $obj2); $actual = FormTagHelper::options_for_select_from_collection($obj_data, 'id', 'name'); $this->assertEquals("<option value=\"1\">one</option>\n<option value=\"2\">two</option>\n", $actual, 'should output correct option tags'); $actual = FormTagHelper::options_for_select_from_collection($obj_data, 'id', 'name', 1); $this->assertEquals("<option value=\"1\" selected=\"selected\">one</option>\n<option value=\"2\">two</option>\n", $actual, 'should mark selected values'); }