mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 07:05:40 +08:00
DEV: add addError method to FormKit onRegisterApi (#28436)
This commit adds the addError method to From's onRegisterApi to allow parent components to add errors to a field.
This commit is contained in:
parent
e9b427ff53
commit
070025204d
app/assets/javascripts/discourse
@ -42,6 +42,7 @@ class FKForm extends Component {
|
|||||||
setProperties: this.setProperties,
|
setProperties: this.setProperties,
|
||||||
submit: this.onSubmit,
|
submit: this.onSubmit,
|
||||||
reset: this.onReset,
|
reset: this.onReset,
|
||||||
|
addError: this.addError,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.on("routeWillChange", this.checkIsDirty);
|
this.router.on("routeWillChange", this.checkIsDirty);
|
||||||
|
@ -137,6 +137,12 @@ module("Integration | Component | FormKit | Form", function (hooks) {
|
|||||||
await formApi.submit();
|
await formApi.submit();
|
||||||
|
|
||||||
assert.dom(".bar").hasText("2");
|
assert.dom(".bar").hasText("2");
|
||||||
|
|
||||||
|
formApi.addError("bar", { title: "Bar", message: "error_foo" });
|
||||||
|
// assert on the next tick
|
||||||
|
setTimeout(() => {
|
||||||
|
assert.form().hasErrors({ bar: "error_foo" });
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("@data", async function (assert) {
|
test("@data", async function (assert) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user