Hi,
We need to create a yes/no question where there can´t be any option selected default.
From what I can tell it´s not possible to create radiobuttons without a pre-selected option with Even Organiser?
Thanks!
AK
Not via the form customiser. You can add the field via the API and not set the ‘selected’ property or you could get the radio element you’ve added (ID 23 in the example below) and unset the selected
property:
<?php
add_action( 'eventorganiser_get_event_booking_form', 'add_field_to_booking_form', 10, 2 );
function add_field_to_booking_form( $form, $event_id ){
$radio = EO_Booking_Form_Element_Factory::create( array(
'type' => 'radio',
'id' => 'my-unique-id', //Must be unique in the form. You should not use 'name', 'ticketpicker', 'gateway' or 'email' as an ID,
'label' => 'Select an option:',
'options' => array( 'A' => 'Option A', 'B' => 'Option B', 'C' => 'Option C' ),
'required' => true, //Default is false
'description' => "Pick one of the options",
) );
$form->add_element( $radio );
}
add_action( 'eventorganiser_get_event_booking_form', 'add_edit_field_booking_form', 10, 2 );
function add_edit_field_booking_form( $form, $event_id ){
$element = $form->get_element( 23 );
$element->set( 'selected', null );
}
Stephen Harris