Changeset 732
- Timestamp:
- 10/08/07 16:55:50 (1 year ago)
- Files:
-
- plugins/merb_helpers/lib/form_helpers.rb (modified) (2 diffs)
- plugins/merb_helpers/specs/merb_helpers_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/merb_helpers/lib/form_helpers.rb
r731 r732 66 66 end 67 67 68 def name(col) 69 "#{@_object_name}[#{col}]" 70 end 71 72 def value(col) 73 @_obj.send(col) 74 end 75 68 76 def name_value(col, attrs) 69 {:name => "#{@_object_name}[#{col}]", :value => "#{@_obj.send(col)}"}.merge(attrs)77 {:name => name(col), :value => value(col)}.merge(attrs) 70 78 end 71 79 … … 122 130 end 123 131 132 def text_area_control(col, attrs = {}) 133 errorify_field(attrs, col) 134 text_area_field(value(col), attrs.merge(:name => name(col))) 135 end 136 137 def text_area_field(val, attrs = {}) 138 open_tag("textarea", attrs) + 139 val + 140 "</textarea>" 141 end 142 124 143 def submit_button(contents, attrs = {}) 125 144 attrs.merge!(:type => "submit") plugins/merb_helpers/specs/merb_helpers_spec.rb
r731 r732 177 177 end 178 178 179 describe "text area (basic)" do 180 include TagMatchers 181 it "should should return a basic text area based on the values passed in" do 182 text_area_field("foo", :name => "foo").should match_tag(:textarea, :name => "foo") 183 end 184 end 185 186 describe "text area (data bound)" do 187 it_should_behave_like "FakeBufferConsumer" 188 189 it "should return a bound text area" do 190 form_for :obj do 191 ta = text_area_control(:foo) 192 tab = text_area_control(:foobad) 193 ta.should match_tag(:textarea, :name => "obj[foo]") 194 tab.should match_tag(:textarea, :name => "obj[foobad]", :class => "error") 195 ta.should include("foowee") 196 end 197 end 198 end 199 200 179 201 describe "submit_button" do 180 202 it_should_behave_like "FakeBufferConsumer"
