form: validate forms only when submitting dossier, not on draft saves
This commit is contained in:
parent
2a8dbf521d
commit
f781399309
2 changed files with 10 additions and 2 deletions
|
@ -55,7 +55,15 @@ addEventListener('turbolinks:load', function() {
|
|||
// the attached files, and then fire the submit action again – but forgetting
|
||||
// which button was clicked. So we manually set the type of action that trigerred
|
||||
// the form submission.
|
||||
hiddenInput.value = button.getAttribute('data-action');
|
||||
var action = button.getAttribute('data-action');
|
||||
hiddenInput.value = action;
|
||||
// Some form fields are marked as mandatory, but when saving a draft we don't want them
|
||||
// to be enforced by the browser.
|
||||
if (action === 'submit') {
|
||||
button.form.removeAttribute('novalidate');
|
||||
} else {
|
||||
button.form.setAttribute('novalidate', 'novalidate');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
- if apercu
|
||||
- form_options = { url: '', method: :get, html: { class: 'form', multipart: true } }
|
||||
- else
|
||||
- form_options = { html: { class: 'form', multipart: true } }
|
||||
- form_options = { html: { class: 'form', multipart: true, novalidate: dossier.brouillon? } }
|
||||
|
||||
= form_for dossier, form_options do |f|
|
||||
= f.fields_for :champs, dossier.champs do |champ_form|
|
||||
|
|
Loading…
Reference in a new issue