Skip to content

Instantly share code, notes, and snippets.

@derekprior
Created February 11, 2012 20:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekprior/1804165 to your computer and use it in GitHub Desktop.
Save derekprior/1804165 to your computer and use it in GitHub Desktop.
Multiple Inline Inputs with Simple Form
= 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'
.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
// using bootstrap sass
.nested-fields {
@extend p;
margin-left: 160px
}
.nested-fields-link {
display: block;
margin-left: 160px;
padding-top: 6px;
}
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