Upload issue when using a drop down form

This topic contains 7 reply and 2 voices, and was last updated by hatchmedia 11 years, 2 months ago
Viewing 7 Posts - 1 through 7 (of 7 total)
Author Posts
September 12, 2013 at 10:29 pm 8093
hatchmedia 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
September 13, 2013 at 12:02 pm 8101
Tareq Hasan Tareq Hasan

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.

September 13, 2013 at 3:59 pm 8103
hatchmedia hatchmedia

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

September 13, 2013 at 4:16 pm 8104
Tareq Hasan Tareq Hasan

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.

September 13, 2013 at 4:18 pm 8105
Tareq Hasan Tareq Hasan

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.

September 13, 2013 at 4:26 pm 8106
hatchmedia hatchmedia

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.

September 13, 2013 at 4:32 pm 8107
Tareq Hasan Tareq Hasan

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

September 13, 2013 at 5:14 pm 8109
hatchmedia hatchmedia

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 7 Posts - 1 through 7 (of 7 total)