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

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

Date disappears if you use bootstrap date picker #41

Open ghost opened 8 years ago

ghost commented 8 years ago

Pull working example from github, dateExample.

I posted this onto stack overflow and it has been flagged as a potential bug. So I was told to post this here.

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.

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>
ghost commented 8 years ago

Is there anyway to get this fixed?

aldeed commented 7 years ago

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

peardigital commented 7 years ago

Dates still disappear when using latest versions: aldeed:autoform@6.0.0 aldeed:autoform-bs-datepicker@2.0.0

Tried using a string instead of Date but still happens

screen shot 2017-03-08 at 14 32 02

theodorosidmar commented 7 years ago

Hello.

I am having the same problem with bootstrap-datetimepicker. When clicking on add or remove, all inputs get in blank.

"agendamentos.$.schedule": { type: Date, label: "Data e hora", autoForm: { afFieldInput: { type: "bootstrap-datetimepicker", dateTimePickerOptions: { format: 'DD/MM/YYYY HH:mm' } } } }