Pull working example from github, dateExample.
I've asked this question before however the suggestion didn't work so I've created a small working example. If someone can point me in the right direction I can put it up online and post the link here. It is a meteor app.
The problem
Autoform generates a form with dates. The form works as an array and uses the bootstrap template which provides some +-
buttons to add
or remove
additional entries. When I use aldeed:autoform-bs-datepicker
a strange problem appears within the form. If you enter a date and hit the +-
buttons before saving, the dates disappear. If you don't use autoform-bs-datepicker
this problem goes away.
See the code below, if there is a way I can post the example up online let me know and I'll do it.
Path: packages.js
twbs:bootstrap aldeed:collection2 aldeed:autoform rajit:bootstrap3-datepicker aldeed:autoform-bs-datepicker
Path: Schemas.js
Classes = new Mongo.Collection("Classes"); var Schemas = {}; Schemas.DatesNotWorking = new SimpleSchema({ name: { type: String, optional: true }, startDate: { type: Date, optional: true, autoform: { type: "bootstrap-datepicker", "data-date-autoclose": "true", datePickerOptions: { format: "yyyy", startView: "years", minViewMode: "years" } } }, endDate: { type: Date, optional: true, autoform: { type: "bootstrap-datepicker", "data-date-autoclose": "true", datePickerOptions: { format: "yyyy", startView: "years", minViewMode: "years" } } } }); Schemas.DatesWorking = new SimpleSchema({ name: { type: String, optional: true }, startDate: { type: Date, optional: true }, endDate: { type: Date, optional: true } }); Schemas.Subjects = new SimpleSchema ({ datesNotWorking: { type: [Schemas.DatesNotWorking], optional: true }, datesWorking: { type: [Schemas.DatesWorking], optional: true } }); Classes.attachSchema(Schemas.Subjects);
Path: dateExample.html
<head> <title>dateExample</title> </head> <body> {{> dateExampleNotWorking}} {{> dateExampleWorking}} </body> <template name="dateExampleNotWorking"> {{#autoForm collection="Classes" id="classesForm" type="update"}} {{> afQuickField name='datesNotWorking'}} <button type="submit" class="btn btn-primary submit">Update</button> {{/autoForm}} </template> <template name="dateExampleWorking"> {{#autoForm collection="Classes" id="classesForm" type="update"}} {{> afQuickField name='datesWorking'}} <button type="submit" class="btn btn-primary submit">Update</button> {{/autoForm}} </template>
0 comments:
Post a Comment