[Closed] Restrict user to select one category only

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Related documentation: Front-end Content Submission and Editing Forms

This topic contains 33 replies, has 2 voices, and was last updated by  Christian Cox 3 months, 3 weeks ago. The support staff assigned to this topic is Christian Cox.

Viewing 15 posts - 16 through 30 (of 34 total)
Author
Posts
#549787

Thanks for that Christian.

OK, I must apologise but my age is obviously catching up with me and I cannot think or understand like I used to!

I have been over and over the link that you give above but simply cannot understand it! 🙁

In the bit about filtering by taxonomy it gives an image. But when I click on 'add a filter' I don't get that image and cannot make any sense of what I should be doing.

#549928

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Instead of clicking "Add New Filter" in the Filter Controls editor, scroll up to the Query Filter section and add the filter here. If you do not see a Query Filter section, scroll all the way up to the top of the screen and click "Screen Options". You'll be able to enable the Query Filter section there. Let me know how it goes.

#549952

I have never used the Filter Editor but always used Query Filter.

When I click Add a Filter at the Query Filter section I do not get a pop up box that looks anything like that in the link you gave.

The View I created was Taxonomy > MyCustomTaxonomy

I tried changing the view to Post types > MyCustomPostType This gives me a choice that looks a bit more like the image in the link, however, it still doesn't allow me to carry on

#550078

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Ok let me jump in and make some adjustments, I'll update you shortly.

#550084

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Please take a look here now:
/add-breed-notes/

Do the select fields show the appropriate options now? I have created a select field for each top-level term in the Breed Notes taxonomy. The terms for each select field are the child terms of that parent term.

So now, you have the ability to select subcategories from the different main categories. Are we heading in the right direction?

Note: - I edited functions.php so you may need to download it and integrate the changes in your local source code.

#550344

OMG! You are amazing!!!!

thank you thank you thank you! I can't thank you enough!!! Now going to scrutinise how it works LOL!

#550345

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Hi, I'm reopening this ticket because we aren't finished yet - the selections in these fields are not saved with the post. There's still a bit of work left to do on that. I just wanted your feedback on whether the options are accurate.

#550407

LOL!!! Thank you Christian!

Yes - they are perfect!

#550482

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Ok next questions:
• Is at least one subgroup selection required?
• What happens if a user selects more than one subgroup? For example, there's nothing to stop a user from selecting Clumber Spaniel and Basenji, from two different main groups. The options are:
- Allow the user to select more than one subgroup, and save both selections
- Show the user a validation error after they submit the form and require them to select only one subgroup before the post is saved
- Refactor this to use a radio button group (only one option can be selected) instead of multiple single select fields

#550612

1) Yes, they MUST select one subgroup

2) As submission will only ever be relevant to just one subgroup the last option of radio button would be best.

#550910

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

Okay I've made the necessary modifications:
- Edited functions.php to remove view 309 from the array of raw text Views
- Added cred_save_data function to functions.php
- Edited your CRED form. You should not use the class "cred-form" in your markup because it conflicts with some code that is required by CRED. I have modified it to be 'cred-form-div-wrapper' instead:

<div class="cred-form-div-wrapper">

- Modified View "Select breed from groups" to place the nested View directly here instead of using a generic field. I found out that it's not possible to split up a generic radio group into multiple Views, so this is the best solution.
- Modified View "Select breed from subgroups" to use basic HTML inputs instead of a generic field, and added some JS code to fix an issue with the labels. I also modified the CSS to add some left padding to each row of inputs.

Please test the Add Breed Note form and let me know if it saves the breed taxonomy term appropriately. Remember to download functions.php updates for your own local copies.

#551226

Yep - it works fine.

The only thing is (and you're going to hate me!!) I wanted them in a drop down box. I didn't think that radio button would be a list, not drop down!

Never mind though. It works 🙂 Thank you

#551570

I have just tried adding two new sub-categories but they are not showing up on the 'Add Breed Notes' form. How do I get them to show on that for user to select please?

#551744

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

How do I get them to show on that for user to select please?
Hi, please see the attached screenshot. In a View of taxonomy terms, you have the ability to show or hide terms that are not associated with any posts. In the Select Breed from Subgroups View, you should uncheck this option. This will show all the available terms in the radio group.

I wanted them in a drop down box. I didn't think that radio button would be a list, not drop down!
No, unfortunately there is not a good way to combine a radio group and dropdown lists. This would require a custom code solution, though I'm not exactly sure how such an input would work. I know that Bootstrap offers an "accordion" collapsible component: hidden link

#551989

Thanks, new groups are now showing.

Whilst that accordion looks great, I have never worked with bootstrap before (I'm very old school, started pre windows! and once you are my age it's hard to learn new things!) I know html and css and that's it. Anything knew is difficult for me.

It was perfect when you did the drop down boxes - is it possible for me to do that instead of radio buttons?

Viewing 15 posts - 16 through 30 (of 34 total)

The topic ‘[Closed] Restrict user to select one category only’ is closed to new replies.