Permalink
Browse files

Added support for image_submit tag built into the form_builder itself…

… purely for consistency
  • Loading branch information...
1 parent 0e31510 commit c3a8dfdc9cf5033fb2eebd5d3195352a85207c0c @nesquena committed Nov 25, 2008
Showing with 31 additions and 5 deletions.
  1. +2 −1 README
  2. +13 −0 lib/semantic_fields_renderer.rb
  3. +16 −4 lib/semantic_form_builder.rb
View
@@ -25,7 +25,8 @@ Works with Rails 1.X as well as 2.X, including 2.2.2
* text_area (attribute:symbol, options_hash:hash)
* check_box (attribute:symbol, options_hash:hash)
* radio_buttons (attribute:symbol, options_hash:hash)
- * submit_button (label:string) - create a submit button in a definition item
+ * submit_button (label:string) - create a submit button in a definition item
+ * image_submit_button (src:string) - create an image submit button in a definition item
These methods can be used within the context of a form builder or within any form as simple helper tags:
@@ -82,6 +82,19 @@ def submit_tag(label, options={})
end
end
+ # places a image_submit_button in a standardized format with a definition item for a standard form.
+ #
+ # <dd class="button"><input id="someid" type ='submit' /></dd>
+ #
+ # ex: f.image_submit_tag 'some_image.png'
+ #
+ def image_submit_tag(image_file, options={})
+ content_tag(:dd, :class => 'button') do
+ @super.image_submit_tag(image_file, options)
+ end
+ end
+
+
# ===============================================================
# PRIVATE HELPERS
# ===============================================================
@@ -13,7 +13,8 @@
* text_area (attribute:symbol, options_hash:hash)
* check_box (attribute:symbol, options_hash:hash)
* radio_buttons (attribute:symbol, options_hash:hash)
- * submit_button (label:string) - create a submit button in a definition item
+ * submit_button (label:string) - create a submit button in a definition item
+ * image_submit_button (src:string) - create an image submit button in a definition item
This form builder is rather easy to use as the example illustrates:
@@ -43,7 +44,6 @@
<dt><label for="user_password_confirmation">Password Confirmation:</label></dt>
<dd><input type="password" size="30" name="user[password_confirmation]" id="user_password_confirmation"/></dd>
- <dt class="button"/>
<dd class="button"><input type="submit" value="Sign up" name="commit"/></dd>
</dl>
</fieldset>
@@ -77,18 +77,30 @@ def fieldset(name=nil, &block)
# submit element tag for form within a definition item
#
- # <dt class="button"></dt>
# <dd class="button">
# <input class="button" type="submit" value="Submit"/>
# </dd>
#
# ex.
- # f.submit_button "Label"
+ # f.submit_button 'Label'
#
def submit_button(label, options={})
@renderer.submit_tag(label, options)
end
+ # image submit element tag for form within a definition item
+ #
+ # <dd class="button">
+ # <input class="button" type="submit" value="Submit"/>
+ # </dd>
+ #
+ # ex.
+ # f.submit_button 'some_image.png'
+ #
+ def image_submit_button(image_file, options={})
+ @renderer.image_submit_tag(image_file, options)
+ end
+
# options => :choices [Array]
# constructs a group of radio buttons based on the choices given within a definition item
#

0 comments on commit c3a8dfd

Please sign in to comment.