Last active
July 16, 2018 13:22
-
-
Save flexbox/5932968 to your computer and use it in GitHub Desktop.
ruby on rails - simple_form syntax helper
This file contains hidden or 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
= f.input :name, input_html: { autofocus: f.object.name.blank? } |
This file contains hidden or 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
# jQuery analytics tracking code | |
= simple_form do |f| | |
= f.association :brand, input_html: { class: 'js-smart-search', data: { placeholder: 'Foo', placeholder: 'Bar' } } |
This file contains hidden or 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
= f.input :mobile, as: :tel | |
= f.input :phone, as: :tel | |
= f.input :fax, as: :tel |
This file contains hidden or 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
# HTML5 Search input | |
= simple_form | |
= search_field_tag :search, id: "search_field", placeholder: "Rechercher", "autosave" => "" |
This file contains hidden or 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
= main_address_form.input :salutation, label: false, include_blank: '-' | |
, { prompt: '-' } |
This file contains hidden or 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
SimpleForm.setup do |config| | |
# Custom wrapper for custom_foundation_project forms. | |
config.wrappers :custom_foundation_project, tag: 'div', error_class: 'error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label | |
b.use :input | |
b.use :error, wrap_with: { tag: 'small', class: 'error' } | |
end | |
# Style for required fields. | |
config.label_text = lambda { |label, required| "#{label} #{required}" } | |
end |
This file contains hidden or 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
# Custom wrapper for project | |
= simple_form_for [:account, address], wrapper: :custom_foundation_project, html: { class: 'custom' } do |form| | |
# Wrapper HTML | |
= simple_form | |
= form.input :engraving, wrapper: 'checkbox_right', wrapper_html: { class: 'no-left-label' }, label: t('.engraving') |
epodczaszy-silicon
commented
Dec 3, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment