Meteor-Community-Packages / meteor-autoform-bs-datepicker

Custom "bootstrap-datepicker" input type for AutoForm
MIT License
25 stars 32 forks source link

Date Does Not Set Set To Value In Array #26

Closed nspangler closed 7 years ago

nspangler commented 9 years ago

I have a collection named Projects in which I need the user to be able to edit previously recorded values.

Say I have schema defined as:

Projects.attachSchema(new SimpleSchema({
   milestones : {
           type : [Object],
           label: "Milestones",
           optional: true
   },
   'milestones.$.name': {type: String, label:"Milestone", optional: true},
    milestones.$.dueDate': {
          type: Number,
          autoform: {
          type: "bootstrap-datepicker"
        },
         optional: true
    },
    milestones.$.completed': {
       Type: Boolean,
       optional: true,
        label: "Completed"
   }.....

And I use it in an autoform as such:

    {{#autoForm collection="Projects" id="newProject" doc=this}}
        <fieldset>
            <legend>Project Goals</legend>
            {{> afQuickField name='milestones'}}
        </fieldset>
        <button  type="submit" class="btn btn-primary"><b>NEXT</b></button>
    {{/autoForm}}

All of the values get set appropriately in the collection, including the chosen date as a Number. However when I navigate back to the form all of the values are set inside of the inputs except the value of the milestone.$.dateDate. When using the datepicker outside of an array I have been able to set the value using a technique like so:

   {{> afQuickField name='startDate' type="bootstrap-datepicker" value=convertDate}}

Where instead of returning the dueDate value as a Number, I convert it to .toLocaleDateString(). This works fine. I tried a similar technique with #afEachArrayItem.

      {{#afEachArrayItem name='milestones'}}
           {{> afQuickField name=this.current.name}}
           {{> afQuickField name=this.current.dueDate  type="bootstrap-datepicker" value=convertDate}}
      {{/afEachArrayItem}}

But was unable to successful get that to work. Any thoughts?

aldeed commented 7 years ago

Closing old issues. Can be reopened if it's still an issue in the latest release.