Created
February 11, 2012 20:54
-
-
Save derekprior/1804165 to your computer and use it in GitHub Desktop.
Multiple Inline Inputs with Simple Form
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
= simple_form_for [:admin, @holiday_schedule] do |f| | |
= render 'error_messages', target: @holiday_schedule, f: f if @holiday_schedule.errors.any? | |
= f.input :name | |
.control-group | |
= f.label :holidays | |
= f.simple_fields_for :holidays do |holiday| | |
= render 'holiday_fields', f: holiday | |
.nested-fields-link | |
= link_to_add_association t('actions.add', | |
:model => Holiday.model_name.human.titleize), f, :holidays | |
.form-actions | |
= f.button :submit, :class => 'btn-primary' |
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
.nested-fields | |
= f.input :name, :wrapper => :nested | |
= f.input :occurs_on, :as => :string, :wrapper => :nested, :input_html => {:class => 'datepicker'} | |
= link_to_remove_association t('actions.delete'), f |
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
// using bootstrap sass | |
.nested-fields { | |
@extend p; | |
margin-left: 160px | |
} | |
.nested-fields-link { | |
display: block; | |
margin-left: 160px; | |
padding-top: 6px; | |
} |
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
config.wrappers :nested, :tag => 'span', :class => 'control-group', :error_class => 'error' do |b| | |
b.use :placeholder | |
b.use :input | |
b.use :error, :tag => 'span', :class => 'help-inline' | |
b.use :hint, :tag => 'p', :class => 'help-block' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment