Bug with FES

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27932

    In file event-organiser-fes/includes/actions.php, for the function function _eo_es_process_event_submission( $form ), for the case default (custom taxonomy)

    Line 296 is $terms = array_map( ‘intval’, $element->get_value() );

    It needs to be $terms = array_map( ‘intval’, $element->get_value(‘terms’) );

    for the custom taxonomy to be saved after creating it as in the last post of this thread
    https://wp-event-organiser.com/forums/topic/extending-fes-like-the-booking-form/, else the custom taxonomy won’t save.

    Regards

    Sadik Bhimani
    #27943

    Hi Sadik,

    The custom taxonomy template doesn’t support creating new terms. Unless you’ve edited the template to support this, $element->get_value() (for the custom taxonomy field) will return an array of IDs which need to be cast to integers.

    Stephen Harris
    #27945

    Hi Stephen

    Apologies I did not perhaps fully explain. I am not trying to save new taxonomy terms. I have associated a new taxonomy with the event custom post type and added the taxonomy as a drop down with wp_dropdown_categories in the template eo-event-form-custom-taxonomy.php in my child theme.

    Now when I am submitting the form having selected a taxonomy from the drop down, the taxonomy actually does not get associated with the event. This is due to the missing ‘terms’ call in the code.

    If I change

    array_map( ‘intval’, $element->get_value() );

    to

    array_map( ‘intval’, $element->get_value(‘terms’) );

    The taxonomy gets associated with the event. Hence I submitted this bug report.

    Regards

    Sadik Bhimani
    #27970

    I think I understand you now. wp_dropdown_categories(), by default, will generate a different mark-up to the checklist that the template generates. In particular, the location of the selected ID(s) in the $_POST array will be different. This isn’t a bug, with FES, you just need to ensure any changes to the template do not cause any changes to the $_POST structure.

    FES expects the the IDs of the selected terms to be array stored at:

     $_POST['eventorganiser']['event_form'][<field id>]
    

    If using wp_dropdown_categories() to replace the default eo_fes_terms_checklist(), the following should achieve that:

     wp_dropdown_categories( array(
        'taxonomy' => $this->element->get_taxonomy() . '[]',
        'name' => $this->element->get_field_name(),
        'hide_empty' => false,
    ) );
    
    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 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.