node.jsmeteormeteor-autoform

MeteorJS - Error: "autoform" is not a supported property


I updated from collection2 to collection2-core@2.x.x. Removed the meteor package aldeed:simple-schema and added the NPM version simpl-schema. I'm using aldeed:autoform@6.0.0 Now the autoform field in my schemas is not working.

What should I do?

This is my schema:

Articulos.schema = new SimpleSchema({
  _id: {
    type: String,
    regEx: SimpleSchema.RegEx.Id,
    optional: true
  },
  nombre: {
    type: String,
    label: 'Nombre',
  },
  area: {
    type: String,
    label: 'Area',
    autoform: {
      firstOption: "Seleccione un area",
      options() {
        var areas = Areas.find({}).fetch();
        const areasOpt = areas.map((a) =>{
          return {
            label: a.nombre,
            value: a.nombre
          }
        });
        return areasOpt;
      }
    }
  },
}

The complete error is the following:

Error: Invalid definition for area field: "autoform" is not a supported property
at /home/francisco/Proyectos/simple-stock/node_modules/simpl-schema/dist/SimpleSchema.js:991:13
at Function._.each._.forEach (/home/francisco/Proyectos/simple-stock/node_modules/underscore/underscore.js:158:9)
at checkAndScrubDefinition (/home/francisco/Proyectos/simple-stock/node_modules/simpl-schema/dist/SimpleSchema.js:989:24)
at /home/francisco/Proyectos/simple-stock/node_modules/simpl-schema/dist/SimpleSchema.js:500:9
at Function._.each._.forEach (/home/francisco/Proyectos/simple-stock/node_modules/underscore/underscore.js:158:9)
at SimpleSchema.extend (/home/francisco/Proyectos/simple-stock/node_modules/simpl-schema/dist/SimpleSchema.js:488:28)
at new SimpleSchema (/home/francisco/Proyectos/simple-stock/node_modules/simpl-schema/dist/SimpleSchema.js:109:10)
at meteorInstall.imports.api.articulos.articulos.js (imports/api/articulos/articulos.js:18:20)
at fileEvaluate (packages/modules-runtime.js:333:9)
at require (packages/modules-runtime.js:228:16)

Solution

  • I found the answer. Had to add the following line:

    SimpleSchema.extendOptions(['autoform']);