The ability to use dyanmicFields in children fields.
jase-languasco opened this issue · comments
Current Behavior
I received this error: inputField keys must be unique for each action, even if they're children. The key "undefined" is already in use at creates.x.operation.inputFields[5].children[2].key
Desired Behavior
{
key: 'field',
label: 'Field',
children: [
(z, bundle) => myChildDynamicField(z, bundle),
],
}
ah, that's a bug! I can fix it.
You'll still want to make sure the fields returned by myChildDynamicField
have unique keys, but the static checker won't flag them for you.
Thanks for reporting!
This issue has been copied into our private issue tracker (as PDE-3003). Thanks for the report! We'll update this as we learn more.
The same function I'm using on the child field is being used on another action as a primary inputField and it's working fine.
You can reuse the function, you just want to avoid this:
fields: [
{ key: 'name' },
children: [
() => { key: 'name' }
]
]
Though, now that I look, I think I've fixed this issue before. What version of zapier-platform-core
does your app depend on?
Ah ok, I realized what's going on.
The actual issue is that the children
field, by definition, can't have dynamic fields. The schema specifies that it only allows field
objects.
The functional validator that checks for unique keys is throwing an error because it doesn't expect non-objects in children
, which is obscuring the actual schema error. When I fixed the validator locally, it told me that creates.x.operation.inputFields[5]
isn't valid because its children are of the wrong type.
So, there's two things here:
- The feature request to be able to use dynamic fields in
children
- Getting you unblocked today
For 1 - we can file the request with our editor team. They'll know best whether that's possible or not.
For 2 - consider not using children
if you can avoid it. Depending on your use case, there may be another way to get the same effect.
@xavdid Thank you for the recommendation. This particular action has lots of fields so being able to group a subset with children was going to be a nice enhancement, but maybe another day! Thank you for your help!
Depending on your use case, there may be another way to get the same effect.
@xavdid Is there another way to group fields? I can't recall seeing anything in the documentation.
There's not another way to group fields at this time, but it's a common request. It's definitely on our radar! A lot of people reach for children
, since it does provide some nice UI. But, it's also got implications for how the data is structured, so we don't always recommend it for that use.
Okay, thanks for letting me know. I look forward to what you all come up with. In this particular case, the UI and the data structure of children is ideal, so I hope that children can support dynamicFields at some point!
Thanks again for all your help!