How do we set initial values for a LIST in the Content Editor of a custom widget?

Options
visioncraft
visioncraft Member Posts: 151 Learner
edited October 2023 in Ask a Question

I'm creating a widget that will have a very simple List field in its Content Editor — each item in the list only has 1 field.

By default, I'd like the widget to be initialised with 3 items on its list, and each item with a different value — i.e., when the widget is dragged onto the Editor, the list in the Content Editor should have 3 unique values. Right now, when I select the 'Default Number of Items' on the List, it populates them all with the same, default value I entered for the item…

Is this possible to do? Or must all the list items have the same value at the start?

Answers

  • Aj_Cre8
    Aj_Cre8 Member Posts: 665 MVP
    Options

    You would need to use some JS in the widget builder that assigned each child in the list a new value. You can also use a Random Function to make the values different as well.

  • ScottyStrehlow
    ScottyStrehlow Member Posts: 308 Duda Staff
    Options

    Hi @visioncraft - this is a good question. I have a colleague I can ask once they return from PTO!