Hi Stephen
Is it possible to customise the booking form? Is there a template to do this?
It appears that the booking form is injected into the_content() but I’d like to place it elsewhere and also modify the form code to fit with the framework I’m using.
Is this possible?
Thanks
-
This topic was modified 9 years, 9 months ago by
David McCourt.

David McCourt
Hi David,
The booking form templates can be found in event-organiser-pro/templates/booking-form
.
However, there are also filters in place to inject framework classes. For instance, the following should ensure the form works well with Bootstrap:
/**
* Examples of filters themes can use to easily style the booking form
*/
function mytheme_booking_button_classes( $class, $form ){
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class
if( 'eo-booking-button' == trim( $class ) ){
$class = 'btn btn-primary eo-booking-button';
}
return $class;
}
add_filter( 'eventorganiser_booking_button_classes', 'mytheme_booking_button_classes', 10, 2 );
/**
* Assign appropriate default classes to error/warning notices
*/
function mytheme_booking_error_classes( $class, $form ){
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class
if( 'eo-booking-error' == trim( $class ) ){
$class = 'alert alert-error';
}
return $class;
}
add_filter( 'eventorganiser_booking_error_classes', 'mytheme_booking_error_classes', 10, 2 );
/**
* Assign appropriate default classes to notices
*/
function mytheme_booking_notice_classes( $class, $form ){
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class
if( 'eo-booking-notice' == trim( $class ) ){
$class = 'alert alert-info';
}
return $class;
}
add_filter( 'eventorganiser_booking_notice_classes', 'mytheme_booking_notice_classes', 10, 2 );
/**
* Assign appropriate default classes to form elements
*/
function mytheme_booking_element_classes( $class, $element ){
$ignore = array( 'html', 'hidden', 'fieldset', 'terms_conditions', 'hook', 'section', 'button' );
if( !in_array( $element->type, $ignore ) ){
$class .= ' form-control ';
}
return $class;
}
add_filter( 'eventorganiser_booking_element_classes', 'mytheme_booking_element_classes', 10, 2 );

Stephen Harris
Hi Stephen
Thanks for your response and apologies for my slow reply but I was on holiday last week.
That information is useful but I would like to add a class to the form tag itself, which is required for the framework I’m using. I can do this via jQuery but I wondered if it was possible with a filter.
Also, I want to position the form outside of the the_content() but I don’t want to use a short code. I’d prefer to do this in the single-event.php template. Is this possible?
Thanks

David McCourt
Hi David,
There’s no filter for adding classes to the from tag (probably should be), but there is a template file (event-organiser-pro/templates/eo-booking-form.php
) you can copy to your theme (theme root directory) and edit it there (it will survive plug-in updates).
To display a booking form in a template file you can do the following:
echo eo_get_booking_form( $event_id );
Where $event_id
is the ID of the event. You can suppress the booking form being automatically added to the event page you can do the following:
add_filter( 'eventorganiser_pro_get_option_disable_automatic_form', '__return_true' )

Stephen Harris