If autosave={true}, the form is validated immediately.
If the autosave is enabled after it is rendered (like the uniforms.tools demo is) then validation does not occur until after the first change, but if its enabled at the time of form render, the validation occurs immediately.
I have tried multiple schemas, and allowed AutoForm to use default field components both with the same results.
Using bootstrap4, Simple Schema 2
Hello there, thanks for reporting. This may be closely related with #204. Let me investigate this later today, ok?
Sure thing, no rush - I put a workaround in place which works by not setting autosave until onChange is triggered the first time:
const autosave = this.state[`autosave-${key}`] || false;
<AutoForm
onSubmit={input => this.handleSaveShop({ input, uq, location })}
schema={formSchema}
model={shop}
className="form-inline"
onChange={() => this.setState({ [`autosave-${key}`]: true })}
autosave={autosave}
>
@todda00 could you share an example of schema what behaves like this?
This is the simpler of the 2 I tested it with:
export const schema = new SimpleSchema({
_id: { type: String, regEx: SimpleSchema.RegEx.Id, optional: true },
title: String,
industry: String,
sampleLink: { type: String, optional: true },
introText: { type: String, optional: true },
standardQuestions: { type: String, optional: true },
minimumReimbursement: Number,
cost: Number,
published: {
type: Boolean,
defaultValue: false,
},
});
Thank you. I'm guessing right now, but it's caused by defaultValue - I'll get to it soon.
EDIT 1: It's not.
EDIT 2: Making every field optional _(or rendering a form with predefined values)_ works. Source.
I had that thought as well, but I removed the defaultValue from the schema and it still validates immediately.
Do you know that moment, when you start debugging something and result in rewriting a part of the core functionality? No? We are not similar then. It's fixed now and will be released soon, but it's worth mentioning, that uniforms will be faster now. Like, really faster for bigger forms.
_All tests are passing, I hope everything works..._
Most helpful comment
Do you know that moment, when you start debugging something and result in rewriting a part of the core functionality? No? We are not similar then. It's fixed now and will be released soon, but it's worth mentioning, that uniforms will be faster now. Like, really faster for bigger forms.
_All tests are passing, I hope everything works..._