FIX: Empty param-inout form should reject submit (#309)
The `onSubmit` hook will only be triggered when the form is valid, so we need to clear the contents of `serializedData` in advance in `submit`. Otherwise, it may not throw a validation error.
This commit is contained in:
@@ -278,6 +278,7 @@ export default class ParamInputForm extends Component {
|
||||
if (this.form == null) {
|
||||
throw "No form";
|
||||
}
|
||||
this.serializedData = null;
|
||||
await this.form.submit();
|
||||
if (this.serializedData == null) {
|
||||
throw new ParamValidationError("validation_failed");
|
||||
@@ -293,7 +294,6 @@ export default class ParamInputForm extends Component {
|
||||
|
||||
@action
|
||||
onSubmit(data) {
|
||||
this.serializedData = null;
|
||||
const serializedData = {};
|
||||
for (const [id, val] of Object.entries(data)) {
|
||||
serializedData[id] =
|
||||
|
||||
@@ -91,7 +91,7 @@ export default class GroupReportsShowController extends Controller {
|
||||
} catch (error) {
|
||||
if (error.jqXHR?.status === 422 && error.jqXHR.responseJSON) {
|
||||
this.results = error.jqXHR.responseJSON;
|
||||
} else if (error instanceof ParamValidationError) {
|
||||
} else if (!(error instanceof ParamValidationError)) {
|
||||
popupAjaxError(error);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user