vue-formulate icon indicating copy to clipboard operation
vue-formulate copied to clipboard

Access the index of current item in a group for a schema-defined generated form

Open Taso69 opened this issue 4 years ago • 3 comments

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 ?

Taso69 avatar Jan 28 '21 23:01 Taso69

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.

justin-schroeder avatar Feb 08 '21 15:02 justin-schroeder

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 avatar Mar 11 '21 00:03 XGhozt

@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

davidtowoju avatar Mar 15 '21 13:03 davidtowoju