document.addEventListener('DOMContentLoaded', function() {
  var form = document.getElementById(#{String fvId}).closest('form');


  var formSubmit = form.querySelector('input[type=submit], button[type=submit]:not(.btn-mass-input-add):not(.btn-mass-input-delete)');
  var cellInputs = Array.from(form.querySelectorAll('.massinput--cell input:not([type=hidden])'));

  cellInputs.forEach(function(input) {
    window.utils.setup('implicitSubmit', input, { submit: formSubmit });
  });


  Array.from(form.querySelectorAll('.massinput--add')).forEach(function(wrapper) {
    var addSubmit = wrapper.querySelector('.btn-mass-input-add');
    var addInputs = Array.from(wrapper.querySelectorAll('input:not([type=hidden]):not(.btn-mass-input-add)'));

    addInputs.forEach(function(input) {
      window.utils.setup('implicitSubmit', input, { submit: addSubmit });
    });
  });
});
