Default value

This topic contains 7 replies, has 4 voices, and was last updated by  Stephen Harris 2 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #33826

    With out default value in fields, this plugin no useful for my project. Please add this in update.

    Dmitri Nepo
    #33828

    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
    #33889

    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
    #39867

    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
    #39901

    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
    #39902

    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
    #42148

    Hi Stephen! The code above you showed Vic, where would you place that?

    Thanks

    Richard

    Richard
    #42170
    Stephen Harris
Viewing 8 posts - 1 through 8 (of 8 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.