Created
January 18, 2016 00:10
-
-
Save rossshannon/048545e20260c05e1db5 to your computer and use it in GitHub Desktop.
Custom FormBuilder subclass to enable simple Ladda-enabled form buttons in Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FormElementsBuilder < ActionView::Helpers::FormBuilder | |
# This is added to the normal form builder options, by adding | |
# <%= form_for(resource, as: resource_name, url: registration_path(resource_name), builder: FormElementsBuilder) do |f| %> | |
# then call it like this: <%= f.ladda_submit_button "Sign up" %> | |
def ladda_submit_button(label, *args) | |
options = args.extract_options! | |
behaviour = options[:behaviour] || 'expand-left' | |
@template.content_tag("button", {class: "ladda-button submit", 'data-style' => behaviour }) do | |
@template.content_tag("span", label.to_s.humanize, class: 'ladda-label') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment