Do not crash with champ repetable with no children

This commit is contained in:
Paul Chavard 2019-11-05 16:54:43 +01:00
parent f5c80f211d
commit a708b071dd

View file

@ -1,10 +1,11 @@
- champs = champ.rows.last - champs = champ.rows.last
- index = (champ.rows.size - 1) * champs.size - if champs.present?
%div{ class: "row row-#{champs.first.row}" } - index = (champ.rows.size - 1) * champs.size
- champs.each.with_index(index) do |champ, index| %div{ class: "row row-#{champs.first.row}" }
= fields_for "#{attribute}[#{index}]", champ do |form| - champs.each.with_index(index) do |champ, index|
= render partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: champ, form: form } = fields_for "#{attribute}[#{index}]", champ do |form|
= form.hidden_field :id = render partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: champ, form: form }
= form.hidden_field :_destroy, disabled: true = form.hidden_field :id
%button.button.danger.remove-row = form.hidden_field :_destroy, disabled: true
Supprimer %button.button.danger.remove-row
Supprimer