diff --git a/app/javascript/controllers/destinations_controller.js b/app/javascript/controllers/destinations_controller.js index 521ed46..a7566cf 100644 --- a/app/javascript/controllers/destinations_controller.js +++ b/app/javascript/controllers/destinations_controller.js @@ -10,11 +10,11 @@ export default class extends Controller { const newDestination = this.templateTarget.content.cloneNode(true) const inputs = newDestination.querySelectorAll('input') const id = this.formTarget.childElementCount - for (let i = 0; i < inputs.length; i++) { - inputs[i].setAttribute('name', inputs[i].getAttribute('name').replace('[template]', `[destinations_attributes][${id}]`)) - inputs[i].setAttribute('id', inputs[i].getAttribute('id').replace('[template]', `destinations_attributes_${id}`)) - inputs[i].value = '' - } + inputs.forEach(input => { + input.setAttribute('name', input.getAttribute('name').replace('[template]', `[destinations_attributes][${id}]`)) + input.setAttribute('id', input.getAttribute('id').replace('[template]', `destinations_attributes_${id}`)) + input.value = '' + }) newDestination.querySelector('div').classList.add(this.paddingWebClass, this.paddingMobileClass) this.formTarget.appendChild(newDestination) this.errorRemoveTarget.classList.add(this.hideClass) diff --git a/app/views/purchases/new.html.erb b/app/views/purchases/new.html.erb index c40ed3d..f34402a 100644 --- a/app/views/purchases/new.html.erb +++ b/app/views/purchases/new.html.erb @@ -40,7 +40,7 @@ <%= image_tag('remove.svg', class:'img-destinations')%> -
La entrega debe tener al menos un destinatario
+La entrega debe tener al menos un destinatario