Support

Account

Home Forums Front-end Issues Datepicker doesn't update field value on month / year change. Reply To: Datepicker doesn't update field value on month / year change.

  • Okay, I found some pointer from zilveer, here:
    https://support.advancedcustomfields.com/forums/topic/adding-custom-javascript-to-date-and-time-picker-fields/
    and also here:
    https://www.advancedcustomfields.com/resources/acf-input-admin_footer/
    With this result, that seems to be working!

    
    <?
    function my_acf_input_admin_footer() {
    ?>
    <script type="text/javascript">
    (function($) {
    	acf.add_filter('date_picker_args', function( args ){
        args['onChangeMonthYear'] = function(y, m, i){
            var d = i.selectedDay;
            $(this).datepicker('setDate', new Date(y, m-1, d));
        }
    		return args;
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
    ?>