CMS Development

jshockey
Participant

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

Hi,

 

I have a module with a repetable group. I set the default object count to 9 in the repeater options. I would like to give each of the 9 objects their own initial default content. Currently, each object pulls in the default content from the fields default content within the group.  See attached photos. How can I give the 9 default instances their own default content?Current values (pulled in from default field content)Current values (pulled in from default field content)Values I would like to be default for each of the 9 default objectsValues I would like to be default for each of the 9 default objects

 

Best,

 

John

0 Upvotes
2 Accepted solutions
Jsum
Solution
Key Advisor

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

Hi @jshockey ,

 

While it is not possible to give items in a repeater field their own default content, you can do this on the template level. Once you add the module to a template you are able to make edits to the module, and the content you add/change in the module will stick to the template, which will transfer over to any pages created with that template.

View solution in original post

tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

You can do this through the CLI, if you edit the module/fields.json file
locate the group you are trying to target

{"tab" : "CONTENT",
  "expanded" : false,
  "type" : "group",
  "default" : {"feature_title": "Resource Database": "stat_number": "9.3"}
}

and convert the "default" object to an array with []
and add objects to the array like so

{"tab" : "CONTENT",
  "expanded" : false,
  "type" : "group",
  "default" : [
    {"feature_title": "Resource Database": "stat_number": "9.3"},
    {"feature_title": "Resource Allocation": "stat_number": "1.2"},
    {"feature_title": "Workload Capacity": "stat_number": "8.0"},
    {"feature_title": "Time Tracking": "stat_number": "6.8"}
  ]
}

 

Be sure to refresh the page editor before adding a new instance of this module, and then you should see 4 repeater objects if you add a new instance of the module to the page.

View solution in original post

5 Replies 5
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

You can do this through the CLI, if you edit the module/fields.json file
locate the group you are trying to target

{"tab" : "CONTENT",
  "expanded" : false,
  "type" : "group",
  "default" : {"feature_title": "Resource Database": "stat_number": "9.3"}
}

and convert the "default" object to an array with []
and add objects to the array like so

{"tab" : "CONTENT",
  "expanded" : false,
  "type" : "group",
  "default" : [
    {"feature_title": "Resource Database": "stat_number": "9.3"},
    {"feature_title": "Resource Allocation": "stat_number": "1.2"},
    {"feature_title": "Workload Capacity": "stat_number": "8.0"},
    {"feature_title": "Time Tracking": "stat_number": "6.8"}
  ]
}

 

Be sure to refresh the page editor before adding a new instance of this module, and then you should see 4 repeater objects if you add a new instance of the module to the page.

lindahouben
Contributor | Elite Partner
Contributor | Elite Partner

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

Hi @tjoyce, i'm having the same issue that I would like to give unique values to repeated items. For me I would like to change a colour for each of the items. Is that also possible with JSON? And what of the code you gave do I need to adjust? 

0 Upvotes
Jsum
Solution
Key Advisor

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

Hi @jshockey ,

 

While it is not possible to give items in a repeater field their own default content, you can do this on the template level. Once you add the module to a template you are able to make edits to the module, and the content you add/change in the module will stick to the template, which will transfer over to any pages created with that template.

ACBlack
Member | Platinum Partner
Member | Platinum Partner

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

And how do you do this? can i ask for an example pice of code?

 

0 Upvotes
jshockey
Participant

Unique default content per each default object instantiated from a repeatable group module.

SOLVE

@Jsum Thanks for the response!