Bug/Feature Booking Form Date Field Date Range

WordPress Event Management, Calendars & Registration Forums Report A Bug Bug/Feature Booking Form Date Field Date Range

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 8 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23812

    This is somewhat of a bug/feature request depending on how you look at it. The long and the short of it is I’ve added a date field to the booking form to capture the users birthdate, unfortunately the date picker is locked to a 20 year span around today which doesn’t make much sense for a birthdate field and it does not appear to be configurable in any way.

    Thanks

    Kyle Klaus
    #23824

    Hi Kyle,

    Its possible to configure the behaviour of the datepicker – but there’s no UI for doing so. You’ll have to make the changes using code in a custom plugin / theme’s functions.php.

    More details can be found on this page: http://wp-event-organiser.com/blog/announcements/event-organiser-pro-1-11-0-rc1/ but here’s an example:

    add_action( 'eventorganiser_get_event_booking_form', 'my_set_datepicker_settings', 10, 2 );
    function my_set_datepicker_settings( $form, $event_id ) {
    
        //Get the datepicker to edit
        $datepicker = $form->get_element( 7 ); //change to ID of datepicker
    
        if ( ! $datepicker ) { 
             return;
        }
    
        //Get the data attribute (this will be an array)
        $data = $datepicker->get( 'data' );
    
        //Set the data attributes as required
        $data['dp_min-date'] = '+0d'; //Only allow dates after today
        $data['dp_max-date'] = '+20y'; //... and before 20 years time
        $data['dp_year-range'] = 'c-0:c+15'; //Restrict the year dropdown to +15 years
        $data['dp_append-text'] = '(dd-mm-yyyy)'; //Append text to the field
        $data['dp_show-week'] = true; //show week numbers
    
        //Update the datepicker with the new data attributes
        $datepicker->set( 'data', $data );
    
    }
    
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.