lucasefe/themes_for_rails — Issue #40: Add theme_image_submit_tag
Author: arufanov
Created: 2012-01-12 08:06:11+00:00
State: open

Hi!

Rails has helper image_submit_tag, but gem not. This is possible to add a code like this to implement: theme_image_submit_tag.
"
# Displays an image which when clicked will submit the form.
#
# source is passed to AssetTagHelper#path_to_image
#
# ==== Options
# * :confirm => 'question?' - This will add a JavaScript confirm
# prompt with the question specified. If the user accepts, the form is
# processed normally, otherwise no action is taken.
# * :disabled - If set to true, the user will not be able to use this input.
# * Any other key creates standard HTML options for the tag.
#
# ==== Examples
# image_submit_tag("login.png")
# # =>
#
# image_submit_tag("purchase.png", :disabled => true)
# # =>
#
# image_submit_tag("search.png", :class => 'search_button')
# # =>
#
# image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")
# # =>
def theme_image_submit_tag(source, options = {})
options.stringify_keys!

if confirm = options.delete("confirm")
add_confirm_to_attributes!(options, confirm)
end

tag :input, { "type" => "image", "src" => theme_image_path(source) }.update(options.stringify_keys)
end
"
There is only one difference at line: "tag :input, { "type" => "image", "src" => theme_image_path(source) }.update(options.stringify_keys) ", I am using theme_image_path rather that path_to_image. Do you need some extra info? I am ready to provide it (I have neve submit patch before, but ready if it is necessary some help will be provided if necessary). Are you planning to include this code into gem?

Artem.