Skip to content

Commit

Permalink
Added possibility to use browser builtin submit (#227)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Burzynski <[email protected]>
  • Loading branch information
stephankaag and Nopik authored Feb 8, 2020
1 parent 1c5cc12 commit cf59e1c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var Formsy = function (_React$Component) {
};

_this.submit = function (event) {
if (event && event.preventDefault) {
if (_this.props.preventDefaultSubmit && event && event.preventDefault) {
event.preventDefault();
}

Expand Down Expand Up @@ -376,6 +376,7 @@ var Formsy = function (_React$Component) {
isValidValue = _this$props.isValidValue,
mapping = _this$props.mapping,
onChange = _this$props.onChange,
preventDefaultSubmit = _this$props.preventDefaultSubmit,
onInvalidSubmit = _this$props.onInvalidSubmit,
onInvalid = _this$props.onInvalid,
onReset = _this$props.onReset,
Expand All @@ -389,7 +390,7 @@ var Formsy = function (_React$Component) {
showError = _this$props.showError,
showRequired = _this$props.showRequired,
validationErrors = _this$props.validationErrors,
nonFormsyProps = _objectWithoutProperties(_this$props, ['getErrorMessage', 'getErrorMessages', 'getValue', 'hasValue', 'isFormDisabled', 'isFormSubmitted', 'isPristine', 'isRequired', 'isValid', 'isValidValue', 'mapping', 'onChange', 'onInvalidSubmit', 'onInvalid', 'onReset', 'onSubmit', 'onValid', 'onValidSubmit', 'preventExternalInvalidation', 'resetValue', 'setValidations', 'setValue', 'showError', 'showRequired', 'validationErrors']);
nonFormsyProps = _objectWithoutProperties(_this$props, ['getErrorMessage', 'getErrorMessages', 'getValue', 'hasValue', 'isFormDisabled', 'isFormSubmitted', 'isPristine', 'isRequired', 'isValid', 'isValidValue', 'mapping', 'onChange', 'preventDefaultSubmit', 'onInvalidSubmit', 'onInvalid', 'onReset', 'onSubmit', 'onValid', 'onValidSubmit', 'preventExternalInvalidation', 'resetValue', 'setValidations', 'setValue', 'showError', 'showRequired', 'validationErrors']);

return _react2.default.createElement('form', _extends({
onReset: _this.resetInternal,
Expand Down Expand Up @@ -470,6 +471,7 @@ Formsy.defaultProps = {
onValid: function onValid() {},
onValidSubmit: function onValidSubmit() {},
preventExternalInvalidation: false,
preventDefaultSubmit: true,
resetValue: function resetValue() {},
setValidations: function setValidations() {},
setValue: function setValue() {},
Expand Down Expand Up @@ -500,6 +502,7 @@ Formsy.propTypes = {
onValid: _propTypes2.default.func,
onValidSubmit: _propTypes2.default.func,
preventExternalInvalidation: _propTypes2.default.bool,
preventDefaultSubmit: _propTypes2.default.bool,
resetValue: _propTypes2.default.func,
setValidations: _propTypes2.default.func,
setValue: _propTypes2.default.func,
Expand Down
Loading

0 comments on commit cf59e1c

Please sign in to comment.