Creating a list from buttons

Hi

I’'ve created a checklist where each question has 3 options. When the button is pressed it sets the state of the group (each question) and uses conditions to set the buttons colour change.

I need to add the list of checked answers to a database, so that I can use dynamic data on a page that is a duplicate in order to create a PDF of the whole thing.

I just can’t get my head around how to set the list, save it to data base.. :frowning:

1 Like

Hey @parkesdude :waving_hand:

That is a very common issue for people that are learning Bubble. Hope we can help. :blush:
How do you have the page set up? Are you using a repeating group to display the list there?

Hi J805

No repeating groups,

I have a main group, with groups inside for each question. Each question has Text and 3 buttons. the total checklist will be around 27 questions.

Got it. So I would recommend creating a template of these values in the database. Then when they choose an option, you can just save it into the database as they choose. That seems like the easiest way to go.

Either, create a copy of those questions for each user or create them as you press the button.

Does that make sense? Need me to set up an example? There are probably a few ways to do this, this just seems like the easiest.

I don’t know why my mind is blanking on this problem so bad, but I don’t get it.

Do you mean set up a field for each question and save its answer to that field?

It would be a data record for each question. Then maybe an option set for the value on that dataType as well.

For example:

DataType: Question

  • Question (Text)
  • Choice (Option Set)
  • Template (yes/no)

Option Set: Choice

  • Yes
  • No
  • N/A

You can follow the backend structure suggested by @J805, and to handle the user responses, you can set a workflow for each of the three answer buttons.

Each workflow should create a new entry in a data type called Answers, with fields like:

Data Type: Answers

  • User (type: User) – the person who answered the question
  • Question_relation (type: Question) – the related question
  • Choice (type: Option Set) – the selected answer

This way, each time a user selects an option, the workflow stores their response in the database, keeping everything organized and linked.

I would actually just use the same DataType but Template=No for the answers. Thus eliminating the extra dataType. :blush: Either way should work though.

Also, it should only create a thing when it hasn’t been created already too.