Created
May 28, 2013 12:35
-
-
Save andreaseriksson/5662460 to your computer and use it in GitHub Desktop.
RAILS Simple form
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
f.error_messages | |
f.input :username | |
f.button :submit | |
f.input :username, label: 'Your username please' | |
f.input :password, hint: 'No special characters.' | |
f.input :email, placeholder: '[email protected]' | |
f.input :remember_me, inline_label: 'Yes, remember me' | |
f.input :username, label_html: { class: 'my_class' } | |
f.input :password, hint: false, error_html: { id: 'password_error'} | |
f.input :password, input_html: { maxlength: 20 } | |
f.input :remember_me, input_html: { value: '1' } | |
f.input :description, as: :text | |
f.input :accepts, as: :radio_buttons | |
f.input :age, collection: 18..60 | |
f.input :username, disabled: true, hint: 'You cannot change your username.' | |
f.input :age, collection: 18..60, prompt: "Select your age" | |
f.input :country_id, collection: @continents, as: :grouped_select, group_method: :countries | |
#Associations | |
f.association :company #belongs_to :company | |
f.association :roles #has_and_belongs_to_many :roles | |
#Associations as.. | |
f.association :company, as: :radio_buttons | |
f.association :roles, as: :check_boxes | |
#Collection Radio Buttons | |
f.collection_radio_buttons :options, [[true, 'Yes'] ,[false, 'No']], :first, :last | |
#Collection Check Boxes | |
f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last | |
#Custom inputs | |
# app/inputs/currency_input.rb | |
class CurrencyInput < SimpleForm::Inputs::Base | |
def input | |
"$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe | |
end | |
end | |
f.input :money, as: :currency |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment