mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Display error message when form submission returns error
This commit is contained in:
parent
cae6dd412c
commit
81602512a5
4 changed files with 13 additions and 5 deletions
|
|
@ -540,7 +540,7 @@ class InvenTreeAPI {
|
|||
* Perform a HTTP POST request
|
||||
* Returns a json object (or null if unsuccessful)
|
||||
*/
|
||||
Future<APIResponse> post(String url, {Map<String, dynamic> body = const {}, int expectedStatusCode=201}) async {
|
||||
Future<APIResponse> post(String url, {Map<String, dynamic> body = const {}, int? expectedStatusCode=201}) async {
|
||||
|
||||
HttpClientRequest? request = await apiRequest(url, "POST");
|
||||
|
||||
|
|
@ -763,7 +763,7 @@ class InvenTreeAPI {
|
|||
* Perform a HTTP GET request
|
||||
* Returns a json object (or null if did not complete)
|
||||
*/
|
||||
Future<APIResponse> get(String url, {Map<String, String> params = const {}, int expectedStatusCode=200}) async {
|
||||
Future<APIResponse> get(String url, {Map<String, String> params = const {}, int? expectedStatusCode=200}) async {
|
||||
|
||||
HttpClientRequest? request = await apiRequest(
|
||||
url,
|
||||
|
|
|
|||
|
|
@ -597,12 +597,14 @@ class _APIFormWidgetState extends State<APIFormWidget> {
|
|||
if (method == "POST") {
|
||||
return await InvenTreeAPI().post(
|
||||
url,
|
||||
body: data
|
||||
body: data,
|
||||
expectedStatusCode: null
|
||||
);
|
||||
} else {
|
||||
return await InvenTreeAPI().patch(
|
||||
url,
|
||||
body: data,
|
||||
expectedStatusCode: null
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -660,6 +662,10 @@ class _APIFormWidgetState extends State<APIFormWidget> {
|
|||
return;
|
||||
case 400:
|
||||
// Form submission / validation error
|
||||
showSnackIcon(
|
||||
L10().error,
|
||||
success: false
|
||||
);
|
||||
|
||||
// Update field errors
|
||||
for (var field in fields) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue