Meteor-Community-Packages / Meteor-Community-Packages/meteor-autoform-select2
Multiple Select2 onSubmit inserts null values
- Dominant language
- JavaScript
- Stars
- 25
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
When I submit my form, multiple select2 field sends only null values. If I manually modify within the mongo collection, When I edit the document I can see the values in the field. If I update them, again, null values are sent to the document in the collection.
Any Ideas?
I really appreciate your help.
Thanks.
###### lib/emergencies.js
``` javascript
Emergencies.attachSchema(new SimpleSchema({
operators: {
type: String,
label: "Operators",
optional: true,
autoform: {
type: "select2",
afFieldInput: {
multiple: true
},
options: function () {
return Employees.find().map(function (c) {
return {label: c.name, value: c.name};
});
}
}
}
}));
```
###### client/emergencies/create.html
``` html
Emergency services bulletin
{{#autoForm collection="Emergencies" id="emergency_new"}}
Operators
{{> afFieldInput name='operators' type="select2" multiple=true}}
Cancel
Save
{{/autoForm}}
```
###### client/afhooks.js
``` javascript
var emergencyHooks = {
onSubmit: function(insertDoc, updateDoc, currentDoc) {
Meteor.call('addEmergencyRecord',insertDoc);
this.done();
},
after: {
insert: function(){
Router.go('/emergencies');
}
}
};
AutoForm.addHooks('emergency_new', emergencyHooks);
```
###### server/methods.js
``` javascript
Meteor.methods({
counter: function(counter){
var result = incrementCounter('Counter','counter');
console.log(result);
return result;
},
addEmergencyRecord: function(doc){
doc.consecutivo = incrementCounter('EmergencyCounter','counter');
return Emergencies.insert(doc);
}
});
```
###### Meteor List
``` linux
accounts-password 1.1.4 Password support for accounts
aldeed:autoform 5.7.1* Easily create forms with automatic insert and update, and automatic reactive validation.
aldeed:autoform-bs-datepicker 1.1.1 Custom bootstrap-datepicker input type for AutoForm
aldeed:autoform-bs-datetimepicker 1.0.6 Custom bootstrap-datetimepicker input type with timezone support for AutoForm
aldeed:autoform-select2 2.0.2 Custom select2 input type for AutoForm
aldeed:collection2 2.5.0* Automatic validation of insert and update operations on the client and server.
aldeed:tabular 1.4.2 Datatables for large or small datasets in Meteor
blaze-html-templates 1.0.1 Compile HTML templates into reactive UI with Meteor Blaze
cfs:autoform 2.2.1 Upload files as part of autoform submission
ecmascript 0.1.6* Compiler plugin that supports ES2015+ in all .js files
ejson 1.0.7 Extended and Extensible JSON library
elevatedevdesign:autoform-slingshot 0.0.6 Slingshot uploader for autoform
es5-shim 4.1.14 Shims and polyfills to improve ECMAScript 5 support
ian:accounts-ui-bootstrap-3 1.2.84 Bootstrap-styled accounts-ui with multi-language support.
iron:router 1.0.12 Routing specifically designed for Meteor
jquery 1.11.4 Manipulate the DOM using CSS selectors
lukemadera:autoform-pikaday 1.0.0 Pikaday date time picker wrapped for autoform
meteor-base 1.0.1 Packages that every Meteor app needs
mobile-experience 1.0.1 Packages for a great mobile user experience
momentjs:moment 2.10.6* Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging
mongo 1.1.3 Adaptor for using MongoDB and Minimongo over DDP
nilsdannemann:pdfmake 1.0.38 Let's you generate PDF's on the client and provides handy features for Layout & Styling.
osv:mongo-counter 0.2.1 Atomic counters stored in MongoDB
rajit:bootstrap3-datepicker 1.4.1* Meteor packaging of eternicode/bootstrap-datepicker for Bootstrap 3
rzymek:moment-locale-es 2.9.0 Moment.js es locale. Companion package for rzymek:moment
session 1.1.1 Session variable
standard-minifiers 1.0.2 Standard minifiers used with Meteor apps by default.
tracker 1.0.9 Dependency tracker to allow reactive callbacks
tsega:bootstrap3-datetimepicker 4.17.37_1 Bootstrap 3 DateTime picker from @Eonasdan, packaged for Meteor.js
twbs:bootstrap 3.3.5* The most popular front-end framework for developing responsive, mobile first projects on the web.
zimme:active-route 2.3.2 Active route helpers
zimme:select2-bootstrap3-css 1.4.6 CSS to make Select2 fit in with Bootstrap 3
```
Contributor guide
Research direction
Start with lib/emergencies.js and client/emergencies/create.html, then trace how the select2 field is passed through client/afhooks.js to server/methods.js. Reproduce the form submission with multiple operators and inspect the document received by addEmergencyRecord. Done means selected values, rather than null values, are stored in the Emergencies collection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100