Reputation: 3417
Did you try adding ?
'name': { type: String, optional: true, uniforms: TextField }
I'm getting an error while trying to implement vazco/uniforms
with simpleschema. The error message is, Invariant Violation: Unrecognised schema: [object Object]
. I'm not sure what this package is asking for.
Path: Schema
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import TextField from 'uniforms-bootstrap3/AutoForm'; // Choose your theme package.
export const ProfileCandidate = new Mongo.Collection('profileCandidate');
const ProfileCandidateSchema = new SimpleSchema({
'name.first': {
type: String,
optional: true,
uniforms: TextField
}
});
ProfileCandidate.attachSchema(ProfileCandidateSchema);
Path: Form
import AutoForm from 'uniforms-bootstrap3/AutoForm';
import ProfileCandidateSchema from '../../../../api/profileCandidate/profileCandidate';
export default class CareerHistoryFormPage extends Component {
constructor() {
super(...arguments);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(doc) {
console.log("Doc: ", doc);
}
render() {
return (
<div className="paper">
<AutoForm schema={ProfileCandidateSchema} onSubmit={this.handleSubmit} />
</div>
);
}
}
Upvotes: 1
Views: 412
Reputation: 25
I ran across this same problem then realized that the ProfileCanidate
schema needs a prop of schema
on your original simple schema, it can't be separately named ProfileCanidateSchema
(which is the syntax I usually use as well). So to edit your code, things should look more along the lines of this:
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import TextField from 'uniforms-bootstrap3/AutoForm'; // Choose your theme
package.
export const ProfileCandidate = new Mongo.Collection('profileCandidate');
ProfileCandidate.schema = new SimpleSchema({
'name.first': {
type: String,
optional: true,
uniforms: TextField
}
});
ProfileCandidate.attachSchema(ProfileCandidate.schema);
and
import AutoForm from 'uniforms-bootstrap3/AutoForm';
import ProfileCandidate from
'../../../../api/profileCandidate/profileCandidate';
export default class CareerHistoryFormPage extends Component {
constructor() {
super(...arguments);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(doc) {
console.log("Doc: ", doc);
}
render() {
return (
<div className="paper">
<AutoForm schema={ProfileCandidate.schema} onSubmit={this.handleSubmit} />
</div>
);
}
}
This should get rid of the Invariant Violation: Unrecognised schema: [object Object]
error for you.
Upvotes: 0