Dynamic Radio Group Name


I’m trying to create a quiz website. I have a CMS that the user can input questions and answers. I wanted to use radio button for the answers but the Radio Group Name doesn’t have that purple button that can make it dynamic based on the CMS. Now, all the answers from every question share the same Radio Group Name.

The only way around this that I can think of is to have a different CMS for every question but it’s not going to be dynamic question-wise.

Is there a way to make the Radio Group Name have a dynamic name?

Hi Jecar,

You can group your CMS lightboxes with SA5’s attributes-

I tried it and my radio buttons does not work anymore.

Ah sorry Jecar, I misread, I was scanning quickly and thought you were asking about lightbox groups. My mind was in the wrong place.

Radio button groups would probably use a similar technique but you will likely need to write your own custom code to set those groups.

One thing you might try is to set the Radio button group directly by assigning the name.

That’s going to be a reserved field, and you won’t be able to create it as a custom attribute, however you may be able to do this with SA5 Dynamic Attributes.

On your radio button element, try putting a custom attribute of x-name and bind it to your CMS group field. Then add the SA5 dynamic attributes lib so that the x-name is converted to a name field at load time.

If Webflow applies that custom attribute directly to the <input> element, then you should successfully have CMS-driven radio button groups.

If not, you’d need to do a similar thing but using an Embed so that you can build the radio buttons explicitly with your assigned name, e.g.;

  <input type="radio" id="banana" name="fruit" value="Banana">
  <label for="banana">Banana</label><br>
  <input type="radio" id="potato" name="fruit" value="Potato">
  <label for="potato">Potato</label><br>
  <input type="radio" id="pear" name="fruit" value="Pear">
  <label for="pear">Pear</label><br>