So let’s say I have a simpl-schema like this:
const SomeItem = new Mongo.Collection("someitems");
Schemas.SomeItem = new SimpleSchema({
_id: {
type: String,
autoValue: function() { return Random.id(); },
},
normalvalue: String,
hiddenvalue: String,
}, {
/* Options for cleaning up the input before insert/update */
clean: {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: true,
removeNullsFromArrays: true,
},
});
SomeItem.attachSchema(Schemas.SomeItem);
const SomeItemList = new Mongo.Collection("someitemlist");
Schemas.SomeItemList = new SimpleSchema({
_id: {
type: String,
autoValue: function() { return Random.id(); },
label: false,
},
title: String,
SomeItems: {
type: Array,
optional: true,
},
"SomeItems.$": Schemas.SomeItem,
unhidablevalue: String,
}, {
/* Options for cleaning up the input before insert/update */
clean: {
filter: true,
autoConvert: false,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: true,
removeNullsFromArrays: true,
},
});
SomeItemList.attachSchema(Schemas.SomeItemList);
And then I have a form like this:
const SomeItemListForm = (props) =>
<AutoForm
// pre-populate model with auto values
model={ Schemas.SomeItemList.clean({}) }
schema={ Schemas.SomeItemList }
>
<AutoFields
omitFields={ [
"_id",
"hiddenvalue",
"unhidablevalue", // This doesn't work
"SomeItems.unhidablevalue", // This also doesn't work
"SomeItems.$._id", // Also doesn't hide the id
"SomeItems.$.unhidablevalue", // Also not working
] }
/>
<ErrorsField />
<SubmitField />
</AutoForm>;
So the problem is that the _id
field and unhidablevalue
are showing up in the subschema (SomeItems
) part of the form despite trying to target omitting it in various ways. Inspecting the element the name of the field is like SomeItems.0._id
. How am I supposed to omit these fields, is omitFields
working for sub schemas at all? Should I abandon this method and try another more verbose solution?