mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 10:19:40 +00: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
@ -42,6 +42,7 @@ class FKForm extends Component {
|
||||
setProperties: this.setProperties,
|
||||
submit: this.onSubmit,
|
||||
reset: this.onReset,
|
||||
addError: this.addError,
|
||||
});
|
||||
|
||||
this.router.on("routeWillChange", this.checkIsDirty);
|
||||
|
@ -137,6 +137,12 @@ module("Integration | Component | FormKit | Form", function (hooks) {
|
||||
await formApi.submit();
|
||||
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user