Basically, I want to add the option to add social links from a predefined list, then add the link url. Nested fields have always got my brain burning.
Edit: Updated to working
{
"fields": [
{
"type": "set",
"label": "Social Account",
"options": {
"fields": [
{
"type": "select",
"name": "action",
"label": "socials",
"options": {
"options": "Facebook, Twitter, Instagram"
}
},
{
"type": "text",
"name": "url",
"label": "link"
}
]
}
}
]
}
Is this the best possible way? There might even be a better way - potentially linking the select to a collection - allowing font-awesome icons and title
How can I prevent the repeater asking me what to add?
If there’s only one field type shouldn’t it simply pick that.
I tried removing the opening and closing of:
{
"fields": [
{
But that just leaves me with a text repeater.
Use field
instead of fields
.
{
field: {"...": "..."}
}
With only one field type the repeater field also produces a nice and clean array instead of the field/value response.
Oh wow, I feel like such a fool right now. Thank you so much!
Edit: Upon doing that it just reverts the set to a text field:
Don’t change fields
to field
in the set, just in the repeater
{
"field":
{
"type": "set",
"label": "Social Account",
"options": {
"fields": [
{
"type": "select",
"name": "action",
"label": "socials",
"options": {
"options": "Facebook, Twitter, Instagram"
}
},
{
"type": "text",
"name": "url",
"label": "link"
}
]
}
}
}
That’s how I’ve got it set:
EDIT: I still had it inside an array.
Thank you!
{
"field":
{
"type": "set",
"label": "Account",
"display": "accounts",
"options": {
"fields": [
{
"type": "select",
"name": "accounts",
"label": "Platform",
"options": {
"options": {
"facebook-f": "Facebook",
"twitter": "Twitter",
"instagram": "Instagram"
}
}
},
{
"type": "text",
"name": "url",
"label": "link"
}
]
}
}
}