-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add field name to WrapIfAdditionalTemplateProps
#3896
Comments
@michal-kurz Why not create a customized version of the WrapIfAdditionalTemplate? You can also use the idSeparator property on |
Yes, this solves my problem, didn't know you could do that, thank you very much! I'm not blocked anymore :)
That's what I was trying to do, if I understand you correctly. But I didn't find a way to access the field name inside my implementation of |
Awesome! Can I close this? |
@heath-freenome Yes, I'll close, sorry. |
Prerequisites
What theme are you using?
core
Is your feature request related to a problem? Please describe.
I want to add a data-testid attribute to all my fields, as suggested in this issue: #1108
WrapIfAdditionalTemplate
template seemed ideal for the job - something like this:But I believe that it is currently not possible to get the field name from
WrapIfAdditionalTemplateProps
.WrapIfAdditionalTemplateProps.id
includes it, but I don't think it's possible to parse it from there reliably, since it also includes all parent fields with separated with_
, so it will be impossible to deremine for fields with underscores in name.Describe the solution you'd like
Add field name to
WrapIfAdditionalTemplateProps
:)This might be useful in other use-cases, also. I can implement this, if you point me to the conceptual solution.
Describe alternatives you've considered
Perhaps I'm missing something, and it's possible to get the name from
WrapIfAdditionalTemplateProps
, or perhaps it's possible to smuggle it inside there somehow :)I also tried importing and wrapping native
FieldTemplate
like this:But surprisingly, this crashes and doesn't even render, plus this would add an additional html element wrapper, which might break some of our layouts. I would prefer to just use
WrapIfAdditionalTemplateProps
:)The text was updated successfully, but these errors were encountered: