Skip to content

Instantly share code, notes, and snippets.

@saroar
Last active July 22, 2016 10:39
Show Gist options
  • Select an option

  • Save saroar/1d5408ea4e9b33091c3d72723e1a838b to your computer and use it in GitHub Desktop.

Select an option

Save saroar/1d5408ea4e9b33091c3d72723e1a838b to your computer and use it in GitHub Desktop.
= semantic_nested_form_for [:admin, @project] do |f|
= f.inputs "Project Details" do
= f.input :start_date, as: :date_picker
= f.input :doc_name
= f.input :project_name
= f.input :end_date, as: :date_picker
= f.input :company_id, as: :select, collection: Company.all.map {|c| [c.company_name, c.id]}
= f.input :working_estimate_id, as: :check_boxes, collection: WorkingEstimate.all.map {|c| [c.working_title, c.id]}
br
br
= f.inputs 'Working Estimates' do
= f.semantic_fields_for :working_estimates do |we|
= we.input :working_title
= we.input :sub_workings, as: :check_boxes, collection: SubWorking.all.map { |s| [s.sub_working_title, s.id] }
br
br
= we.inputs 'Sub Workings' do
= we.semantic_fields_for :sub_workings do |sw|
= sw.input :sub_working_title
= sw.input :working_hour
= sw.input :specialists, as: :check_boxes, collection: Specialist.all.map { |s| [s.sub_working_title, s.id] }
br
br
= sw.inputs 'Specialist' do
= sw.semantic_fields_for :specialists do |s|
= s.inout :name
= s.input :rate
= f.actions do
= f.action :submit
= f.action :cancel
# How to setup params for this :)
permit_params :start_date, :end_date, :doc_name, :project_name, :company_id,
working_estimates_attributes: [:id, :working_title, :_update, :_destroy, sub_working_ids: [],
sub_workings_attributes: [:id, :sub_working_title, :working_hour, specialist_ids: [],
specialist_attributes: [:id, :name, :rate] ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment