Home Forums Plugin Support WP User Frontend Pro Upload issue when using a drop down form

This topic is: not resolved

This topic contains 7 replies, has 2 voices, and was last updated by  hatchmedia 5 years, 10 months ago.

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

    hatchmedia
    Participant
    Post count: 116

    Hi guys,

    I have 4 custom post type that users can upload to. I have created four separate upload forms to allow them the posts go to the correct Custom Post Types with the correct Taxonomies.

    What I want to do is create a drop down menu that displays the 4 upload forms I have created. The user will select which form they want to use and then that will be populated in front of them.

    Here is my code for two of the forms:

    <select id="pet_type" name="pet_type">
       <option>Select a pet type...</option>
       <option value="dog">Submit a Dog</option>
       <option value="cat">Submit a Cat</option>
    </select>
    
    <form id="dog" class="hidden">
    [wpuf_form id="1258"]
    </form>
    
    <form id="cat" class="hidden">
    [wpuf_form id="1267"]
    </form>
    
    <script type="text/javascript">
    jQuery('#pet_type').on('change', function() {
        var val = jQuery(this).val();
        jQuery('#dog').hide();
        jQuery('#cat').hide();
        jQuery('#' + val).show();
    });
    </script>

    This element seems to work, but when I try to upload a photo, two browse windows pop up. If I add a third form, 3 browse windows open and if I add the fourth form, a fourth browse window opens. This only happens on the first form. The second/third/fourth forms dont open any window at all when trying to browse for an image.

    Is there anything I can do to stop this happening?

    Cheers

    Damien

    #8101

    Tareq Hasan
    Keymaster
    Post count: 2831

    You are using multiple forms in the same page, the problem with the uploader is it works based on CSS ID of those fields and which is based on the meta key. So you are using the same meta key for every forms and those buttons are bind to the uploader and this problem happens.

    Either you've to change the meta key for each form or use different pages for forms.

    #8103

    hatchmedia
    Participant
    Post count: 116

    Thanks Tareq!

    I can see how that is an issue alright! Changing the meta fields for the images have worked, but there are no meta fields for the Main Photo, the one that feeds to Featured Image. I have tried amending the CSS classes but that has not helped.

    Is there a way of adding a meta field to the Featured Image box on the form? Which file would I need to amend?

    Cheers

    Damien

    #8104

    Tareq Hasan
    Keymaster
    Post count: 2831

    Adding a field is trickier, you should look into /class/admin-template-post.php for modifying the edit form. /class/render-form.php for rendering the form in frontend.

    #8105

    Tareq Hasan
    Keymaster
    Post count: 2831

    Without using multiple form, may you can create a dropdown at the top of the form for a pet type and show/hide fields with jQuery based on the value.

    #8106

    hatchmedia
    Participant
    Post count: 116

    Thats a good idea but would that work with the different Custom Post Types I have set up?

    Each of the four forms uploads to a different CPT i.e. Dogs, Cats, Farms, Others.

    #8107

    Tareq Hasan
    Keymaster
    Post count: 2831

    That's why filter exists, isn't it? You can change the post type based on the dropdown value by using filter.

    #8109

    hatchmedia
    Participant
    Post count: 116

    Hmm, I think this is where my coding knowledge begins to lack a little! ๐Ÿ™‚

    Let me look into this for a little bit! haha

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Upload issue when using a drop down form’ is closed to new replies.