Time value of Date element not updating

achartier

Super Moderator
Staff member
I have 2 date elements on a form. Each shows the time selector. In the javascript onChange event of the first date element I have a call to function start_date_change(this); This function calls an updEndDate function. Details in the following code segment:
Code:
function updEndDate() {
        var form = getForm();
        var vStartDate = form.formElements.get("tqkjo_appointments___start_date").get("value");
        if (vStartDate == "") {
                /* we don't have a start date yet so wait a bit */
                return;
        }
        var eEndDate = form.formElements.get("tqkjo_appointments___end_date");
        var vDuration = form.formElements.get("tqkjo_appointments___duration").get("value");
//      eEndDate.set(moment(vStartDate).add(vDuration, "minutes").format("YYYY-MM-DD HH.mm.ss"));
        eEndDate.set("2017-12-12 12:12:12");
}
/* Process a change to the start date */
function start_date_change(el) {
        /* We want to adjust the end date based on the duration */
        var form = getForm();
        var curDuration = form.formElements.get("tqkjo_appointments___duration").get("value");

        if (curDuration == "") {
                return;
        }
        updEndDate();
}
function getForm()
{
        var form = Fabrik.getBlock("form_8");
        if (form === false) {
                form = Fabrik.getBlock("details_8");
        }
        return form;
}
As you can see in the updEndDate function I have temporarily hard coded a fix time to set the end_date element to. When the start date element changes all the functions are called correctly but the time portion of the element is not updated. Here is a screen grab of the result:
 

Attachments

  • end_date.png
    end_date.png
    7.7 KB · Views: 26
Hugh, I have just gone ahead and taken out a profession sub. Maybe you can move this to the professional section. Thanks.

You can access the Test Gravit8 site on mysites. Once logged in go to Manage->New Appointment
 
Last edited:
Couple of things, you don't need your getForm() function, the element object you are passed already has a reference to the Fabrik form object, el.form, so el.form.formElements.get('whatever') will do it.

And try update() instead of set(). That should fire the update() methods in the date object, which should know about times.

Hmm, I just tested it and it didn't. I'll take a look later, havce to head out for dinner with family right now.

-- hugh
 
Ah, looks like I broke that in the last commit on the date JS. I've fixed it locally, will commit after testing for a day or two.



Sent from my HTC6545LVW using Tapatalk
 
I have gotten around the issue for now. My application includes a duration field so I am updating the time portion in the form submission plugin. I will remove this code once you commit your changes.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top