mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-01-18 18:46:24 +00:00
Show form validation errors in notification.
This solves #282 because the issue was that auto created measurements did not have a name and without the measurements tab open, the error was not visible. Before ChirpStack v4.5.0 forceRender was not used on the Tabs.TabPane, in which case the validation would not run on unrendered tabs, which explains why the form could be submitted even with the empty measurement names. Closes #282.
This commit is contained in:
parent
a402b487f8
commit
91611b0505
@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
|
||||
import { Form, Input, Select, InputNumber, Switch, Row, Col, Button, Tabs, Modal, Spin, Cascader, Card } from "antd";
|
||||
import { Form, Input, Select, InputNumber, Switch, Row, Col, Button, Tabs, Modal, Spin, Cascader, Card, notification } from "antd";
|
||||
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
|
||||
import {
|
||||
@ -305,6 +305,14 @@ function DeviceProfileForm(props: IProps) {
|
||||
props.onFinish(dp);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {
|
||||
notification.error({
|
||||
message: "Validation errors",
|
||||
description: "Please inspect input fields for errors",
|
||||
duration: 30,
|
||||
});
|
||||
};
|
||||
|
||||
const onSupportsOtaaChange = (checked: boolean) => {
|
||||
setSupportsOtaa(checked);
|
||||
};
|
||||
@ -401,7 +409,7 @@ function DeviceProfileForm(props: IProps) {
|
||||
);
|
||||
|
||||
return (
|
||||
<Form layout="vertical" initialValues={props.initialValues.toObject()} onFinish={onFinish} form={form}>
|
||||
<Form layout="vertical" initialValues={props.initialValues.toObject()} onFinish={onFinish} onFinishFailed={onFinishFailed} form={form}>
|
||||
<TemplateModal visible={templateModalVisible} onOk={onTemplateModalOk} onCancel={onTemplateModalCancel} />
|
||||
<Tabs tabBarExtraContent={operations} activeKey={tabActive} onChange={onTabChange}>
|
||||
<Tabs.TabPane tab="General" key="1" forceRender>
|
||||
|
Loading…
Reference in New Issue
Block a user