Skip to content

Commit

Permalink
fix(form): able to submit when button disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jul 18, 2022
1 parent 39e76c4 commit bf3ebef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,17 @@ var plugin_formcreator = new function() {
return;
}
});
}
};

this.submitUserForm = function (event) {
var keyPressed = event.keyCode || event.which;
if (keyPressed === 13 && $('[name="submit_formcreator"]').is(':hidden')) {
event.preventDefault();
return false;
}

return true;
};
}

// === TARGETS ===
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/userform.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<div class="asset">
{% set formName = 'plugin_formcreator_form' %}
<form name="{{ formName }}" method="post" role="form" enctype="multipart/form-data" class="plugin_formcreator_form" action={{ item.getFormURL() }} id="plugin_formcreator_form" data-itemtype="PluginFormcreatorForm" data-id="{{ item.fields['id'] }}">
<form name="{{ formName }}" method="post" role="form" enctype="multipart/form-data" class="plugin_formcreator_form" action={{ item.getFormURL() }} onkeypress="return plugin_formcreator.submitUserForm(event);" id="plugin_formcreator_form" data-itemtype="PluginFormcreatorForm" data-id="{{ item.fields['id'] }}">
<h1 class='form-title'>
{{ __(item.fields['name'], options.domain) }}
<i class="fas fa-print" style="cursor: pointer;" onclick="window.print();"></i>
Expand Down

0 comments on commit bf3ebef

Please sign in to comment.