Home › Toolset Professional Support › [Resolved] Form Datepicker Not Loading on Only One Form
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 13 replies, has 2 voices.
Last updated by Dave 3 years, 2 months ago.
Assisted by: Shane.
Tell us what you are trying to do?
Use the datepicker for it's intended purpose.
Is there a similar example that we can see?
Yes, it works on every other form I've made.
What is the link to your site?
Links to specific pages can be provided in PM.
Basically, the datepicker is not loading on one of my forms and for the life of me I can't figure out why.
The form is a new content form for a variation of the messaging system you guys have built and has been mentioned in this previous ticket:
https://toolset.com/forums/topic/second-cred-form-view-in-bootstrap-modals-not-loading/
The reply form is a copy of the new form with some modifications, but the datepicker works perfectly on the new form and won't on the reply form. Both forms load in modals, as discussed in the above thread. There is no custom jQuery at work, no errors in the console, nothing. I've tried the generic field as well as the custom field and neither will load but both work in the other form. Here is the form code:
[credform] [cred_field field='form_messages' class='alert alert-warning'] <div class="form-group"> <label for="%%FORM_ID%%_communication-subject">[cred_i18n name='communication-subject-label']Subject[/cred_i18n]</label> [cred_field field='post_title' post='communication' value='Re: [wpv-post-title]' urlparam='' class='form-control' output='bootstrap'] </div> <div class="form-group"> <label for="%%FORM_ID%%_communication-due-date">[cred_i18n name='communication-due-date-label']Due Date[/cred_i18n]</label> [cred_field field='communication-due-date' force_type='field' class='form-control' output='bootstrap'] </div> <div class="row"> <div class="col-md-6"> <label for="%%FORM_ID%%_communication-status">[cred_i18n name='communication-status-label']Status[/cred_i18n]</label> [cred_field field='communication-status' force_type='field' class='form-control' output='bootstrap'] </div> <div class="col-md-6"> <label for="%%FORM_ID%%_communication-assigned">[cred_i18n name='communication-assigned-label']Assigned To[/cred_i18n]</label> [cred_field field='communication-assigned' force_type='field' class='form-control' output='bootstrap'] </div> </div> <div class="form-group"> [cred_generic_field field='wpcf-communication-first-message-id' type='hidden' class='' urlparam=''] { "required":0, "validate_format":0, "persist":1, "default":"[types field='communication-first-message-id']" } [/cred_generic_field] </div> <div class="form-group"> <label for="%%FORM_ID%%_communication-message">[cred_i18n name='communication-message-label']Message[/cred_i18n]</label> [cred_field field='communication-message' force_type='field' class='form-control' output='bootstrap'] </div> <div class="form-group"> [cred_field field='communication-send-to-parent' force_type='field' class='form-check-input' output='bootstrap'] </div> <div class="hide"> [cred_field field='[message_relationship_field_parameter]' class='form-control' output='bootstrap' value='[wpv-post-id id="$current_page"]' select_text='--- not set ---' required='false'] </div> <div class="row"> <div class="col-md-6"> [cred_field field='form_submit' output='bootstrap' value='Save' class='btn btn-primary btn-lg btn-block'] </div> <div class="col-md-6"> <button type="button" class="btn btn-secondary btn-lg btn-block" data-dismiss="modal">Cancel</button> </div> </div> [/credform]
The implementation of the datepicker field:
[cred_field field='communication-due-date' force_type='field' class='form-control' output='bootstrap']
is identical to the way it's used on the other form, but clicking in it has zero effect.
The site is running Hello Elementor and the Toolset plugins, that's it, and switching themes makes no difference.
Oh, and this might be unrelated, but there was one other slight issue with this form, which, to reiterate, is a copy of a fully working form. The message field is a textarea, but it would only load as a single line visually, despite it working perfectly well elsewhere. I had to add this line of CSS to force it back to it's normal size:
.textarea.form-control { height: auto !important; }
Like I said, I don't think it's related, but it is a weird coincidence.
Could someone please help?
Hi Dave,
It's quite possible that the modal is interfering.
What I would do is to remove the form from the modal and test it outside of the modal and to see if the datepicker would load under that scenario.
From there if it works then we can conclude that the modal is interfering.
Thanks,
Shane
Hmmm, I wasn't convinced of this at first as the New Message form is loading in a modal and this one almost exactly the same and also loading in a modal. The New one works fine, but this one doesn't in their current locations.
If I load this form openly onto a content template it works no problem. If I swap the New and Reply forms around so they're called from each others locations then the behaviour swaps. The datepicker on the New form stops working and the Reply one then works correctly.
If you read through the other post I linked in my first message you can get a better feel for the structure here, but essentially the only difference is that the New modal is called from the content template and the Reply modal is called from within the New modal.
How can this be breaking the JS? Is there any alternatives we could use to the inbuilt datepicker anyway, as its a particularly great looking one?
Hi Dave,
Perhaps what we can try is to reinitialise the datepicker JS however i'm not sure this will work. Would you mind providing me with a link to the page where I can see the issue at hand ?
Thanks,
Shane
Sure thing. Turn on a Private Message and I'll send you access, page links etc
Hi Dave,
Here are the private fields.
Also please send me a link to the page where it is working as well.
Thanks,
Shane
Hi Dave,
Ok so i see why this is happening.
Moving the modal from outside of the content template to the loop directly resolves the issue.
Please check now and let me know if everything is ok.
Thanks,
Shane
Hi Shane,
I can see that that does indeed work now, but I have some follow up questions as I don't really understand why.
Here is the View Loop code from before:
[wpv-layout-start] <button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#newCommunicationModal">New Message</button> [wpv-items-found] <!-- wpv-loop-start --> <table width="100%" class="table" data-sorting="true"> <thead> <tr> <th data-sortable="false">Subject</th> <th data-type="date" data-format-string="DD-MM-YYYY">Date</th> <th>Sender</th> <th data-type="date" data-format-string="DD-MM-YYYY">Due Date</th> <th>Assigned To</th> <th>Status</th> </tr> </thead> <tbody class="wpv-loop js-wpv-loop"> <wpv-loop> <tr> [wpv-post-body view_template="loop-item-in-parents-messages"] </tr> </wpv-loop> </tbody> </table> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No messages found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end] <!-- New Message Modal --> <div class="modal fade" id="newCommunicationModal" tabindex="-1" role="dialog" aria-labelledby="newCommunicationModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="newCommunicationModalLabel">New Message</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> [cred_form form="new-communication"] </div> </div> </div> </div>
And the View Content Template:
<td> <a href=# data-toggle="modal" data-target="#viewMessageModal-[wpv-post-id]"> [types field="communication-subject"][/types] </a> <!-- View Message Modal --> <div class="modal fade" id="viewMessageModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="viewMessageModal-[wpv-post-id]" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="viewMessageModal-[wpv-post-id]">Subject: [types field="communication-subject"][/types]</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> [wpv-post-body view_template="read-message"] </div> </div> </div> </div> <!-- Reply Modal --> <div class="modal fade" id="replyModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="replyModalLabel-[wpv-post-id]" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="replyModalLabel-[wpv-post-id]">Reply to: [wpv-post-title]</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> [cred_form form="communication-reply"] </div> </div> </div> </div> </td> <td>[wpv-post-date format="d/m/Y - H:i"]</td> <td>[types field="communication-sender"][/types]</td> <td>[types field="communication-due-date"][/types]</td> <td>[types field="communication-assigned"][/types]</td> <td>[types field="communication-status"][/types]</td>
Now, as you have stated, you've moved the reply modal from the the Content Template into the Loop does indeed cause the datepicker to load again. However, if we look at your updated loop code:
[wpv-layout-start] <button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#newCommunicationModal">New Message</button> [wpv-items-found] <!-- wpv-loop-start --> <table width="100%" class="table" data-sorting="true"> <thead> <tr> <th data-sortable="false">Subject</th> <th data-type="date" data-format-string="DD-MM-YYYY">Date</th> <th>Sender</th> <th data-type="date" data-format-string="DD-MM-YYYY">Due Date</th> <th>Assigned To</th> <th>Status</th> </tr> </thead> <tbody class="wpv-loop js-wpv-loop"> <wpv-loop> <tr> [wpv-post-body view_template="loop-item-in-parents-messages"] </tr> <!-- Reply Modal --> <div class="modal fade" id="replyModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="replyModalLabel-[wpv-post-id]" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="replyModalLabel-[wpv-post-id]">Reply to: [wpv-post-title]</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> [cred_form form="communication-reply"] </div> </div> </div> </div> </wpv-loop> </tbody> </table> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No messages found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end] <!-- New Message Modal --> <div class="modal fade" id="newCommunicationModal" tabindex="-1" role="dialog" aria-labelledby="newCommunicationModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="newCommunicationModalLabel">New Message</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> [cred_form form="new-communication"] </div> </div> </div> </div>
You can see that the New Message Modal is exactly where I had it originally and is outside of the loop, yet this has always worked fine.
Can you explain why this is please so I can better understand the placement of modals going forwards?
I would also like to ask if there is a way of styling or replacing the datepicker with different ones, maybe scrolling wheel number pickers or something. I have no specifics in mind, I would just like the option to choose a more aesthetically pleasing one if it's possible.
Many thanks.
Hi Dave,
Unfortunately this i'm not able to explain as what I did was to first establish that it was actually working when not inside the loop and indeed it did.
Then I compared it to the New Message form when added to the Loop and found that the new message form wasn't loading the datepicker when added to the content template of the view. I also found that the datepicker works when added to the loop but not in the modal.
So I suspect the issue might be just the positioning of the modal and the timing in which items are being loaded to the page. Since there is no clear error or debugging log for this it's only a guess as the clues point to the load order.
Thanks,
Shane
Hmmm, I understand where you're coming from, but it does offer clues at least although it seems very inconsistent.
Seeing as there seems to be a lot of issues surrounding Modals and Toolset, it would be incredibly helpful if you could either fully integrate modal features into Toolset, or provide explicit documentation detailing exactly how they can and cannot be used as it seems to be a very popular feature to use alongside Toolset.
Did you have any thoughts on my other question regarding the possibility of styling or replacing the datepicker?
Hi Dave,
Regarding the question on the datepicker it is possible to do but you're going to have to identify each of the datepicker triggers and their respective css classes in order to style it.
The best way to do this is by inspecting the datepicker element and the datepicker when you've triggered it. See my screenshot for some of the classes.
Thanks,
Shane
Hi Shane,
Thanks for highlighting the styles at work there, I realised I asked the question slightly wrong though, sorry. I meant is there any inbuilt functionality, hooks etc, for manipulating the datepicker, it's functionality and appearance aside from overriding the CSS.
Also is there any way of hooking in a replacement datepicker that operates differently, say with scroll wheels for example to enter a manual date?
Hi Dave,
No there isn't, any modifications to the datepicker would need to be done by using CSS.
Also is there any way of hooking in a replacement datepicker that operates differently, say with scroll wheels for example to enter a manual date?
Usually any modification to the datepicker is done using Javascript and CSS to overwrite the existing default styling and functions.
Thanks,
Shane
Ok, well that's kinda disappointing. Considering it's a core part of your setup it would be very desirable to be able to interact, modify and replace it much more easily than it currently is.
Some examples or links to examples of how to modify it with JS would have been helpful, but I can see this is not really how you intend it to be used.
My original problem has been solved so I'll close the ticket.