Access the index of current item in a group for a schema-defined generated form
Hello everyone,
First of all, thanks for the awesome framework, this is an incredible job !
This might be a documentation request rather than a feature request : I'd like to use the index for the items inside a repeatable group. I can see how it would be done for a "classic" html-defined FormulateForm, but I need to do it from a JSON-defined schema, and {{ index }} doesn't work (and I don't think setting "default": "index" does anything in myGroup ? I don't exactly get how the default slot component may be used from within the JSON schema)
{
"name": "myGroup",
"type": "group",
"repeatable": true,
"default": "index",
"children": [
{
"name": "myCheckbox",
"label": "I am the checkbox {{ index }}",
"type": "checkbox"
}
}
Any ideas ? Any way to access the groupProps from the children ?
Hey @Taso69.
Hmm, not sure there's a good way to do this using a schema necessarily. We're trying to avoid putting expressions in the JSON since then we basically have to create a JSON serializable language 😂.
I'll think on this some as we work on version 3 though.
I achieved this by using a custom plugin/field, however, I'd love to see some basic show/hide logic in the schema though.
Perhaps something like this:
{
"name": "Example"
"show" "field_name:yes"
}
Where another field value makes this field visible or not.
We could raw influence from how laravel handles more complex validation rules.
@XGhozt
I achieved this by using a custom plugin/field, however, I'd love to see some basic show/hide logic in the schema though.
Do you mind sharing how you did this?
Thanks