You want to create a Custom State on your page for example. This CS is of data type “Hobbies” and it is a list.
When one of the options is clicked in your RG, you want to add this hobby to the custom state or remove it when it’s already added. => Action Set state “Hobbies” add “'s hobbies :plus item current cell Hobbies”. On the workflow itself you add an ‘only when’ “'s hobbies doesn’t contain current cell… AND 's hobbies count < 5” and vica versa without the latest AND expression.
On the group/button in your RG you add the following conditional: "When 's hobbies contains current cell => change background for example.
Awesome. I’ll give that a try! Thank you for your response. Can I ask one more question please. How can I do a counter to the text below 0/5 on button clicks.
Hi there, @Dijest… you are on the right track, but you have a couple of issues with your setup that you will need to address before you get to the part that is explained by @olivier.coolen.
First, you have entered all of your options in the Hobbies option set as attributes, not options. So, you will need to delete those attributes and add the options like this.
Next, a user will be able to have more than one hobby, of course, but the Hobby field you created on your User data type isn’t a list. So, you will need to delete that field and create a new field, and when you create the new field, check the This field is a list (multiple entries) checkbox.
Now, as far as a user only being able to select 5 options goes, there are multiple ways to do that, and it kind of depends on the setup of your app. Do you want the hobbies to be saved as soon as the user selects each one? Or do you want them to be saved when a button is clicked? If it’s the latter, then you would probably use a custom state as @olivier.coolen has described. If it’s the former, you could use auto-binding or a workflow to save each selection to the user’s Hobbies field as the selections are made.
Anyway, that’s probably enough for now, and I hope this helps.
Hi Mike, thanks so much for your response. I will definitely go through what you and @olivier.coolen has given me and hopefully not have more questions LOL.
To answer your question about “Do you want the hobbies to be saved as soon as the user selects each one? Or do you want them to be saved when a button is clicked?”
I think I would want it to be saved when the button is clicked “Next:Link your accounts” But there is another step in which they can select another Category. This all seems very complicated now 🫣
See screenshot of what the end result should look like. Appreciate the help from you guys.
It can be a bit tricky, depending on how new you are to Bubble and what your base knowledge of the platform is.
If I remember correctly from your post from yesterday, you have separate pages for each of your steps. So, you will have to save the hobbies as each one is selected or you can use a custom state, and will have to save the items from the state to the user’s Hobbies field when the Next: Link your accounts button is clicked because if you navigate to a new page and you haven’t saved the items from the custom state, those items will be lost.
I just cannot wrap my head around on how to make the button stay yellow and also get the counter to work on button click. I am not a pro in bubble! Would you be able to give me some advice. This is what I’ve got so far
Also not sure how to do this " So, you will have to save the hobbies as each one is selected or you can use a custom state, and will have to save the items from the state to the user’s Hobbies field when the Next: Link your accounts button is clicked because if you navigate to a new page and you haven’t saved the items from the custom state, those items will be lost." tried finding videos online but can’t seem to find any.
Okay, I will walk you through it with an example. In my example, I have an option set called OS Hobbies, a list field on the User data type called hobbies, a custom state at the page level (I am using the index page) called selected hobbies that is a list of OS Hobbies, a repeating group with a data source of All OS Hobbies, and a text element in the repeating group that shows the Current cell's OS Hobbies Display.
When one of the hobbies is clicked in the repeating group, one of two workflows will run. If the hobby has not already been selected, this workflow will run.
Note that the second part of the Only when condition on the workflow event will stop the user from selecting more than 5 hobbies. Here is the action in that workflow.
Thanks for the detailed response, really appreciate the support. I am going through it step by step, but am missing the indexing option on the event state “only when” section. See below. It seems to be what is causing all not to work.
What I gave you is just an example. You have to be able to take the information and apply it to your setup. You won’t select index because that isn’t the page you are on and you didn’t create your custom state on that page. You have to select the page/element on which you created your custom state, and then you will be able to select the state itself. I think yours might be onboarding_step_3 Hobbies.
Ok so I have done all of that and it was working fabulously, but then got this: Sorry, we ran into a temporary bug and can’t complete your request. We’ll fix it as soon as we can; please try again in a bit!
In the debugger it seems to be on the 3rd step. See below. Any ideas? Thanks again!
It WORKED! You are a Genius! Thanks so so much for your help. I’ll have plenty more question in the future. Learning every day cause of helpful people like you! Appreciated!