Skip Navigation

[Resolved] Input date shows blank when trying to use Toolset update post form

This thread is resolved. Here is a description of the problem and solution.

Problem: When using a Toolset Form to edit a post, I am trying to set a minimum date range in the field with custom JavaScript. However, the datepicker field shows blank even if a value is set in wp-admin.

Solution: In this case some custom code is necessary:

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 );
});
This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by stuartm-2 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1318783
buttons that open the form.PNG
blank date.PNG

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>
#1319525

Hi, I just tried to test this and it seems to be working for me...can you clear your browser cache and test again?

#1319901
pop up.PNG

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?

#1321293

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.

#1321821

Yes please let me know

#1324389

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?

#1326761

Thank you for changing the code, it is working properly now.