Skip to content

Commit

Permalink
Added support for image_submit tag built into the form_builder itself…
Browse files Browse the repository at this point in the history
… purely for consistency
  • Loading branch information
nesquena committed Nov 25, 2008
1 parent 0e31510 commit c3a8dfd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README
Expand Up @@ -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:

Expand Down
13 changes: 13 additions & 0 deletions lib/semantic_fields_renderer.rb
Expand Up @@ -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
# ===============================================================
Expand Down
20 changes: 16 additions & 4 deletions lib/semantic_form_builder.rb
Expand Up @@ -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:
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
#
Expand Down

0 comments on commit c3a8dfd

Please sign in to comment.