bekam ich eine verschachtelte Form des Kokon Juwel mit:Zählen hinzugefügten Felder in verschachtelter Form (Kokon)
_form.html.haml:
= simple_form_for @day do |f|
#task
= f.simple_fields_for :tasks do |task|
= render 'task_fields', f: task
.links
= link_to_add_association '+ Aufgabe', f, :tasks
= f.submit
_task_fields.html.haml:
.nested-fields
= f.input :description, label: 'Name/Beschreibung: '
= f.input :ur, as: :range, input_html: { min: '1', max: '4', id: "rangeInput#{@x}", oninput: "rangeOutput#{@x}.value = rangeInput#{@x}.value"}
%output#rangeOutput{:for => "rangeInput#{@x}", :name => "rangeOutput#{@x}"} 3
= link_to_remove_association "remove task", f
days_controller.rb:
def create
@day = current_user.days.build(day_params)
@day.save
respond_to do |format|
if @day.save
format.html { redirect_to @day, notice: 'Day was successfully created.' }
format.json { render :show, status: :created, location: @day }
else
format.html { render :new }
format.json { render json: @day.errors, status: :unprocessable_entity }
end
end
end
ich muss Inkrementieren Sie eine Viariable Evertime die _task_fields-partial
gerendert wird oder die link_to_add_association
gedrückt wird.
Könnten Sie Ihren relevanten Controller-Code teilen? – nicholas79171