Home › Toolset Professional Support › [Resolved] Date-picker broken for all except the first instance on a page
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 |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
Tagged: Content-submission forms, Toolset Forms
Related documentation:
This topic contains 9 replies, has 2 voices.
Last updated by markL 6 years, 6 months ago.
Assisted by: Beda.
Hi there,
I am experiencing the problem described in this post:
https://toolset.com/forums/topic/date-picker-breaks-with-multiple-cred-post-forms-on-1-page/
It was not clear whether this issue was resolved. Would you please confirm the status of this issue?
My implementation includes a page that has a new post form and a view that lists posts of that type along with an edit button that triggers a edit post form in a modal. The date picker works in the first instance of the form, the new post form, but does not appear in the edit post forms. I have noticed that the input element in the subsequent forms, the class attribute does not contain the hasDatepicker value:
<div class="form-group"> <div class="js-wpt-field-items js-wpt-repetitive wpt-repetitive" data-initial-conditional="" data-item_name="date-wpcf-ed-date-of-birth"> <input type="text" id="cred_form_108_2-textfield-4-1530840162" name="wpcf-ed-date-of-birth[display-only]" value="" class="js-wpt-date form-control wpt-form-textfield form-textfield textfield" style="" readonly="readonly" title="Select date" placeholder="Date of birth" data-wpt-type="textfield" data-wpt-id="cred_form_108_2_cred_form_108_2-textfield-4-1530840162" data-wpt-name="wpcf-ed-date-of-birth[display-only]"> <input type="hidden" id="cred_form_108_2-hidden-1-1530840162" name="wpcf-ed-date-of-birth[datepicker]" value="" class="js-wpt-date-auxiliar wpt-form-hidden form-hidden" data-ts="" data-wpt-type="date" data-wpt-id="cred_form_108_2_cred_form_108_2-hidden-1-1530840162" data-wpt-name="wpcf-ed-date-of-birth[datepicker]"><span role="button" href="#" class="js-wpt-date-clear wpt-date-clear dashicons-before dashicons-no" style="display:none"></span></div> </div>
This is in contrast to the same field in the first instance of the form, the new post form:
<div class="form-group"> <div class="js-wpt-field-items js-wpt-repetitive wpt-repetitive" data-initial-conditional="" data-item_name="date-wpcf-ed-date-of-birth"> <input type="text" id="cred_form_109_18-textfield-3-1530840162-8" name="wpcf-ed-date-of-birth[display-only]" value="" class="js-wpt-date form-control wpt-form-textfield form-textfield textfield hasDatepicker" style="" readonly="readonly" title="Select date" placeholder="Date of birth" data-wpt-type="textfield" data-wpt-id="cred_form_109_18_cred_form_109_18-textfield-3-1530840162" data-wpt-name="wpcf-ed-date-of-birth[display-only]"><img class="ui-datepicker-trigger" src="<em><u>hidden link</u></em>" alt="Select date" title="Select date"> <input type="hidden" id="cred_form_109_18-hidden-1-1530840162" name="wpcf-ed-date-of-birth[datepicker]" value="" class="js-wpt-date-auxiliar wpt-form-hidden form-hidden" data-ts="" data-wpt-type="date" data-wpt-id="cred_form_109_18_cred_form_109_18-hidden-1-1530840162" data-wpt-name="wpcf-ed-date-of-birth[datepicker]"><span role="button" href="#" class="js-wpt-date-clear wpt-date-clear dashicons-before dashicons-no" style="display:none"></span></div> </div>
I am not getting any php or js errors. I have tried disabling the only plugin I have installed other than toolset plugins and switching back to Twenty Seventeen but I get the same result
I am getting a warning in the console about a password field:
Input elements should have autocomplete attributes (suggested: "new-password"):
I would appreciate any assistance you can provide on this issue.
Thanks - Mark
Hi again.
I have found that displaying the edit forms on the page instead of in a modal solves the date picker problem, however this is not going to work for this site. I need the modal. Can you advise what might be going wrong here and how to approach a solution?
The modals are generated using the process from bootstrap documentation:
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingOne"> <div class="row"> <div class="col-md-3"> <h4 class="panel-title"> <a role="button" data-toggle="collapse" data-parent="#accordion" href="#educator" aria-expanded="true" aria-controls="collapseOne"> Educators</a> </h4> </div> <div class="col-md-6"> [wpv-filter-start hide="false"] [wpv-filter-controls] <div class="form-group form-inline active"> [wpv-control-postmeta field="wpcf-active-status" url_param="wpv-wpcf-active-status"] <button type="submit" class="btn btn-xs active-btn" name="wpv_filter_submit" > <span class="glyphicon glyphicon-filter" aria-hidden="true"></span> </button> </div> [wpv-filter-end] </div> <div class="col-md-3"> <button type="button" class="btn btn-xs new-record-icon" aria-label="AddRecord" data-toggle="modal" data-target="#newed"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> </button> </div> </div> <!-- New Educator Activity Modal --> <div class="modal fade" id="newed" tabindex="-1" role="dialog" aria-labelledby="newcoLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title" id="newvisitLabel">New Educator</h4> </div> <div class="modal-body">[cred_form form="new-educator"]</div> </div> </div> </div> </div> <div id="educator" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingEdu"> <div class="panel-body"> [wpv-layout-start] [wpv-items-found] <table class="table"> <tbody> <!-- wpv-loop-start --> <wpv-loop> <tr> <td> <a href="[wpv-post-url]">[wpv-post-title]</a> <button type="button" class="btn btn-sm new-record-icon" aria-label="Edit Record" data-toggle="modal" data-target="#editedu-[wpv-post-id]"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> </button> </td> </tr> <!-- Edit Educator[wpv-post-id] modal --> <div class="modal fade" id="editedu-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="editedu[wpv-post-id]Label"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title" id="editcoordLabel">Edit Educator Record</h4> </div> <div class="modal-body">[cred_form form="edit-educator"]</div> </div> </div> </div> </wpv-loop> <!-- wpv-loop-end --> </tbody> </table> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end] </div> </div> </div> </div>
Thanks - Mark
Hello
The issue reported in the linked Ticket, was replicable as follows:
1. Create 2 Toolset Forms (Former CRED) to create new posts
2. Each has a Date Picker in it
3. Add the forms to the same page
4. Try to use the DatePicker
It will work only for the First form.
That issue was resolved within Toolset CRED 1.9.1, which meanwhile is available as Toolset Forms 2.xx versions.
I confirmed that this is resolved locally as well following the steps.
In a Bootstrap Modal I noticed that the forms all take the same value in the date field, means, if you edit the first form's date field in the first modal, and close it, to edit the second date field in the second form/modal, then that date will be using the same value as you set first for the initial form.
That is no problem if you actually submit the form - even if you do that with AJAX, it resets all fields properly.
The only glitch in that case would be if you open modal one, fill a date, and then close the modal so to fill another form's date field.
But you can then still edit it, hence this is not a breaking bug but I will still report this to be adjusted if possible.
Now, the issue you report to me was not replicable, which may be due to several issues.
I suggest you pack up a copy of your site (where you possibly exclude all other plugins / themes) and send this to us
Please let us know where on the site we can see the issue and we will try to find the reason for it and solve.
https://toolset.com/faq/provide-supporters-copy-site/
Thanks!
That is a setup using Toolset Layouts, I used manual HTML and Views/Types/Forms only.
I see that this Layout has a View cell where all the HTML is created.
Note that this View is not properly set.
You added the whole Filter to the Loop, for example:
[wpv-filter-start hide="false"] [wpv-filter-controls] <div class="input-group status"> [wpv-control-postmeta field="wpcf-status" url_param="wpv-wpcf-status" class="input-group-prepend"] <button type="submit" class="btn btn-xs filter-button" name="wpv_filter_submit" > <span class="fa fa-filter" aria-hidden="true"></span> </button> </div> [/wpv-filter-controls] [wpv-filter-end]
Please regenerate a fresh View, and see where the native Shortcodes are placed.
They cannot be used elsewhere.
Then I see that you use HTML wrapping the Loop (as for tabs) and that will as well probably conflict with Views, since Views has a native Loop wrapping HTML output which you can remove only by Custom Code.
However this seems to not be the case here.
But we need to start with a Fresh View, as this is not how the View can work.
I quickly grabbed an export of your site's structure only (only Toolset exports) and recreated it locally to test what I state above.
I suggest to solve this issue as follows:
1. Create 2 Tabs with Toolset Layouts:
https://toolset.com/documentation/user-guides/tabs-cell/
2. In one Tab, insert a View Cell, were you will insert the Edit Form (as you do already) for each post.
Use this code in the freshly created New View Loop where you query "Educators":
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-[wpv-post-id]"> Launch demo modal </button> <!-- Modal --> <div class="modal fade" id="myModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-[wpv-post-id]"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel-[wpv-post-id]">Modal title</h4> </div> <div class="modal-body"> [cred_form form='educator-edit'] </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div> </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
This is vanilla Bootstrap enhanced with Toolset to display a Modal for each Toolset Form.
3. In the other tab insert the Create form as a Cell
I added Screenshots of the local test.
Thanks Beda.
I don't think it has anything to do with the way I have structured the view with respect to the filters.
Before I tried your suggestion with the tabs cells I moved the filter shortcodes back into the search and pagination but this had no effect.
I then tried your suggestion with the tabs cells and your simplified view loop and got the expected behaviour: the date fields worked again.
I then added some simple table markup around the loop and it broke again. I suspect the table is the problem. I removed the table from my original view and the date fields started working as expected.
It seems that when there are table elements inside the loop, the date picker breaks. This seems like a bug.
For example this does not work:
[wpv-layout-start] <table class="table"> <tbody> [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> <tr> <td> <a href="[wpv-post-url]">[wpv-post-title]</a> <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-[wpv-post-id]"> Demo Modal Trigger </button> </td> </tr> <!-- Modal --> <div class="modal fade" id="myModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-[wpv-post-id]"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel-[wpv-post-id]">Modal title</h4> </div> <div class="modal-body"> [cred_form form='educator-edit'] </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div> </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] </tbody> </table> [wpv-layout-end]
But this does work:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> <a href="[wpv-post-url]">[wpv-post-title]</a> <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-[wpv-post-id]"> Demo Modal Trigger </button> <!-- Modal --> <div class="modal fade" id="myModal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-[wpv-post-id]"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel-[wpv-post-id]">Modal title</h4> </div> <div class="modal-body"> [cred_form form='educator-edit'] </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div> </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
What do you think?
Thanks - Mark
Hi again,
As an aside, I have been having a problem with relationship selectors not working in these modals as well.
I just checked and when there's no table markup in the loop, the relationship selectors also come back to life. They have options and parent posts can be pre-selected. This has not been the case when a post fields are displayed in table elements inside the loop.
Would you let me know if I should be thinking of a whole new non-table-based UX for this site?
Thanks - Mark
Yes, there is a problem with tables and forms:
https://toolset.com/forums/topic/error-the-parent-must-be-a-post-id-or-a-wp_post-instance/
That is known and reported but not yet fixed.
If you can confirm this is due just to the table/form, then this is the same issue and I'll add a note that as well the Date Field is broken with this scenario.
Hi again,
Wow - I have just gone back to basics and remembered that you can use the loop wizard to insert a table. This reveals a secret loop item box in the views edit page that only seems accessible through using the wizard and selecting wrap item in a content template.
When I used this function to create the table it all started working again - even the relationships selectors.
I'm not sure why the wizard is not mandatory or alternatively, why the loop item box is not accessible without the wizard.
Anyway - Thanks again,
Mark 🙂
Hi Again,
I had a quick look at
https://toolset.com/forums/topic/error-the-parent-must-be-a-post-id-or-a-wp_post-instance/
This seems to be the same behaviour with date fields and relationship selectors that I have been experiencing and the site seems to have the same table based listing of posts.
Using the wizard to create a template that keeps the <td> elements from appearing directly inside the loop shortcodes has resolved both these issues for me.
I suspect If I created a content template that contained the <td> elements and inserted the shortcode for the template into the loop it would work.
Cheers - Mark
Hi again,
Actually I have now realised that the relationships function is not working properly yet.
When new posts are created using the new post form, the correct parent is displayed in the relationship field in the form, but when submitted, the relationship does not stick. The post is created with no parent.
When the edit forms are rendered, the correct parent is filled in the relationship field and on form submit, the relationship remains.
If I remove the edit forms from the page, the new post form works properly. I will start a new ticket for this issue:
Thanks