Input date shows blank when trying to use Toolset form to update post on the frontend.
This is following this resolved issue https://toolset.com/forums/topic/input-field-of-date-is-read-only/page/2/.
Now i tried to apply that code from the link above inside to update the date field of a custom post with no luck. The form is located inside toggle and inside a popup.
This is in the header of the theme:
<script type="text/javascript">
jQuery(document).ready(function(){
wptDate.init("#cred_form_181_1", {
source: 'cred_form_ready_init'
});
});
</script>
And This is in the content template of posts.
<div class="wpb_wrapper">
<script type="text/javascript">
jQuery(document).ready(function($){ $(".testdate").datepicker( 'option', {showButtonPanel: true, minDate: 0 });});
jQuery(document).ready(function($){ $(".testdate").datepicker({showButtonPanel: true, minDate: 0 });});
</script>
</div>
Hi, I just tried to test this and it seems to be working for me...can you clear your browser cache and test again?
Hello,
I tried with disabled cache, but you have commented the parts that i need. Min dates a user can choose. I need the Toolset form to be located inside the Pop up i created to function properly. Even when you commented the min dates it still shows an empty cell.
What is the issue with this?
Ah yes, sorry I got lost in my own tests. I see the problem here and I can replicate it locally. Normally in the past we could modify the datepicker options on the document load event, but there seems to be a timing issue now. I've asked my second tier team to investigate this and see if the preferred event hook has changed. I'll let you know what I find out.
I just added a small change in your Content Template's JavaScript to work around the event timing issue. Here's the updated code for your reference:
jQuery(document).ready(function($){
setTimeout(function() {
if($( "input.js-wpt-date" )) {
$("input.js-wpt-date").each(function() {
val = $(this).val();
$(this).datepicker( 'option', {showButtonPanel: true, minDate: 0 });
$(this).val(val);
});
}
}, 500 );
});
Since we don't currently have a reliable event hook, a timeout is necessary. Now I see the date displayed correctly in the datepicker, and I also see that the minimum date is enforced as today. Can you confirm it's working more like you expect?
Thank you for changing the code, it is working properly now.