With out default value in fields, this plugin no useful for my project. Please add this in update.
Dmitri Nepo
i finding solution to set default value to all input fields
value=”<?php echo esc_attr( $this->get_value() );?>”
to
value=”MY VALUE”
in file “eo-event-form-input”
Dmitri Nepo
You can do this in code:
add_action( 'eventorganiser_get_fes_form', function( $form ) {
$form->get_element($element_id)->set_value('MY VALUE');
}, 1 );
where $element_id'
is the ID of the form element. If you hard-code the value in the template then you will have the same value for all fields using that template. Additionally it would produce some unintended results when editing events from the front-end, if that is enabled.
Stephen Harris
Stephen,
How do I set the default value of a venue. I only have one so it doesn’t make sense to have the user select it every time. It’s an options pulldown so need to be able to set the option as selected somehow. Using set_value doesn’t work (obviously).
Cheers, Vic
Vic Ratnieks
Hi Vic,
This would pre-select the venue (of ID 2), assuming the venue field had id 3:
add_action( 'eventorganiser_get_fes_form', function( $form ) {
$form->get_element(3)->set_value(array('venue_id'=> 2));
}, 1 );
However, if you have only one venue, and all events will be of that venue you could try doing this instead:
add_filter('eventorganiser_fes_submit_event', function($event, $form){
$event['event-venue'] = 2;
return $event;
}, 10, 2);
which will force the evenue to that of ID 2 (and then remove the field altogether).
Stephen Harris
Thanks Stephen, that worked well. I’ve added another venue now, so using the first option, but the 2nd is a good way to handle single venues for sure.
Cheers, Vic
Vic Ratnieks
Hi Stephen! The code above you showed Vic, where would you place that?
Thanks
Richard
Richard
Stephen Harris