Meteor-Community-Packages / meteor-autoform

AutoForm is a Meteor package that adds UI components and helpers to easily create basic forms with automatic insert and update events, and automatic reactive validation.
MIT License
1.44k stars 328 forks source link

Errors with latest versions of autoform + collection2 + simpl-schema #1654

Closed j-khong closed 3 years ago

j-khong commented 6 years ago

Hi aldeed

First of all, thank you for your contributions : simple-schema, collection2 and autoform are killers

I've recently wanted to switch to simpl-schema (npm package) and i've encountered some errors. Here is how i reproduce the errors

First, set up the project

meteor create test-autoform --release 1.6.1.1
cd test-autoform
meteor add aldeed:collection2 aldeed:autoform
meteor npm install --save simpl-schema

=>aldeed:autoform@6.3.0 =>aldeed:collection2@3.0.0 =>"simpl-schema": "^1.5.0"

Add a little bit of code

// main.js
import SimpleSchema from 'simpl-schema'
BookSchema = new SimpleSchema({
  title: {type: String}
})
Books = new Mongo.Collection('Books')
Books.attachSchema(BookSchema)
// main.html
{{> quickForm collection="Books" id="insertBookForm" type="insert"}}

and then the errors

Exception in template helper: TypeError: Cannot convert undefined or null to object
    at Function.from (native)
    at _toConsumableArray (http://localhost:3000/packages/modules.js?hash=fcf2e0056ef926384482b794e8a7fdc3b4e032d1:1114:182)
    at SimpleSchema.getAllowedValuesForKey (http://localhost:3000/packages/modules.js?hash=fcf2e0056ef926384482b794e8a7fdc3b4e032d1:1711:24)
    at Object.autoFormGetOptionsForField [as _getOptionsForField] (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:2927:24)
    at Object.afQuickFieldsQuickFieldAtts (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:7357:33)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3051:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1715:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3103:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3102:27

Exception in template helper: TypeError: Cannot read property 'singleType' of undefined
    at SimpleSchema.getQuickTypeForKey (http://localhost:3000/packages/modules.js?hash=fcf2e0056ef926384482b794e8a7fdc3b4e032d1:1370:40)
    at Object.getInputType (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:2829:31)
    at Object.bsFormGroupSkipLabel (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:8280:27)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3051:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1715:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3103:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3102:27
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=547cf8e466d1d52603d19bd5f48fb5df184fd237:172:18)
    at Template.afFormGroup_bootstrap3.HTML.DIV.HTML.SPAN.class (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:8236:22)

Exception in template helper: TypeError: Cannot read property 'singleType' of undefined
    at SimpleSchema.getQuickTypeForKey (http://localhost:3000/packages/modules.js?hash=fcf2e0056ef926384482b794e8a7fdc3b4e032d1:1370:40)
    at Object.getInputType (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:2829:31)
    at Object.getTemplateName (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:6934:32)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3051:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1715:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3103:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3102:27
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=547cf8e466d1d52603d19bd5f48fb5df184fd237:172:18)
    at http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:6906:27

Exception in template helper: TypeError: Cannot read property 'singleType' of undefined
    at SimpleSchema.getQuickTypeForKey (http://localhost:3000/packages/modules.js?hash=fcf2e0056ef926384482b794e8a7fdc3b4e032d1:1370:40)
    at Object.getInputType (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:2829:31)
    at Object.afFieldInputContext (http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:6978:32)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3051:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1715:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3103:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3102:27
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=547cf8e466d1d52603d19bd5f48fb5df184fd237:172:18)
    at http://localhost:3000/packages/aldeed_autoform.js?hash=954bc02e0fca04fa83ea45bb5b4206380192fdad:6907:23

thanks in advance

mohsenv commented 6 years ago

Dear Aldeed,

Thanks a lot in advance for support. I have exactly the same errors. Below is my situation Package.json :
"simpl-schema": "^1.5.0"

Meteor Packages : aldeed:autoform materialize:materialize aldeed:collection2-core

parts.js file : import { Mongo } from 'meteor/mongo'; import SimpleSchema from 'simpl-schema'; SimpleSchema.extendOptions(['autoform']);

export const Parts = new Mongo.Collection("parts"); // const Schemas = {};

//Schemas.Part = new SimpleSchema({ Parts.attachSchema(new SimpleSchema({ partNo: { type: String, label:"Part No", max: 500 }, title: { type: String, label: "Title", max: 200 }, summary: { type: String, label: "Summary", optional: true, max: 1000 } }));

nosizejosh commented 6 years ago

same issue here, was not even planning on updating but meteor just refused to work after my windows updated automatically and was forced to update meteor as well as my project to meteor 1.6.1.1 and aldeed:autoform@6.3.0, aldeed:collection2-core@2.1.2 and "simpl-schema": "^1.5.0", Downgrading meteor to 1.6.1 still doesn't solve it. A form that used to work well now looks like this image.

trying to force a downgrade to aldeed:autoform@6.2.0 and aldeed:collection2@2.7.1, aldeed:simple-schema@1.5.4 leads to more errors: Error: Invalid definition for pick field. W20180503-14:27:13.493(0)? (STDERR) at packages\aldeedsimple-schema.js:1429:13 W20180503-14:27:13.494(0)? (STDERR) at Function..each._.forEach (packages\underscore.js:147:22) W20180503-14:27:13.497(0)? (STDERR) at new SimpleSchema (packages\aldeed_simple-schema.js:1426:5) W20180503-14:27:13.498(0)? (STDERR) at ns.Collection.c2AttachSchema [as attachSchema] (packages\aldeed_collection2.js:60:10)

what can we do temporarily to keep the project moving while this is solved?

joystick commented 6 years ago

Hi there,

I hit same issue. After walking my :dog2: :dog2: out and a quick look into debugger I discovered that formId is not being picked up from quickForm template id parameter.

Meanwhile {{#autoForm ...}} variant with afQuickFields works as expected OOB.

Hope this helps.

Best wishes, Alexei

j-khong commented 6 years ago

Hi guys

i've found the solution use npm "simpl-schema": "^1.4.3" instead of 1.5

and make sure you have no meteor-simple-schema deps with others packages (ex meteortoys:allthings)

mohsenv commented 6 years ago

Dear j-khong

Thanks a lot dude. I changed and my issue resolved. Happy coding!

Pierre-Mike commented 6 years ago

I changed the versions, but it didn't change anything. Do you have any other recommendations?

Thank you for your help. It works for me with version 0.5.0 :/

aldeed:autoform@6.3.0 aldeed:collection2@3.0.0

"simpl-schema": "^0.5.0", "babel/runtime": "^7.0.0-beta.42",

andreasteffanoni commented 6 years ago

Thanks j-khong

your solution worked for me as well!

nosizejosh commented 6 years ago

@Pierre-Mike, what worked for me was to change to aldeed:autoform@6.3.0, "simpl-schema": "^1.4.2" make sure simpleschema is not installed and packages like meteortoys:allthings which requires simpleschema is also removed. Also try to run npm install to make sure you have the simpl-schema installed to correct version.

ExcelNet-Public commented 6 years ago

Thanks j-khong

This solution worked for me. Hopefully, we will see a fixed version going forward.

Pierre-Mike commented 6 years ago

ho yes that also works for me now I modified the file "package-lock.json" which had remained on the version of simpl-schema : 1.5.0

Everything works for me. Thanks a lot.

ipstas commented 6 years ago

quickform still doesn't work for me autoform works when it is like that:

{{#each afFieldNames }}
    {{> afQuickField name=this.name}}
{{/each}}
Sebl29 commented 6 years ago

+1 Meteor 1.7.0.4-rc1, simple-schema 1.4.3 works, simple-schema 1.5.3 does not work. (package-lock.json reverted, npm prune, npm install)

catin-black commented 6 years ago

+1

MohammedEssehemy commented 6 years ago

I've opened pull request in simple-schema-js package which hopefully will solve this issue aldeed/simple-schema-js#306

jankapunkt commented 5 years ago

Has been fixed by this PR merge:

https://github.com/aldeed/simple-schema-js/pull/306

jankapunkt commented 3 years ago

This is resolved with the latest SimpleSchem