-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Pass in parameters to custom field when applying component to AutoField. #1231
Comments
Hi @emmett08. It looks like you are creating a custom component. In that case, you probably want to wire it up with the form's model. Here's my first question - what is the Second thing is the And lastly, remember that all fields rendered by uniforms have to be a part of the schema, and if you'd like to render some fields dynamically (e.g., make the number of fields depend on other fields), it has to be reflected in the schema too. |
Hi @radekmie - field was a github copilot addition which I didn't check. How do I pass in the choices array to the component when registering it in an AutoForm please?
This is where I use the component and connectField:
|
In case this helps anyone else...
Usage:
|
I'm glad you figured it out! Just to make it clear: what you proposed in this comment could work, but is not in-align with how uniforms are meant to be used. The And as for this code - you could simplify it a little. The I'll close this one, but feel free to comment further. |
Firstly, thank you to make uniforms open source. I'm trying to create a generic checkbox list to show in AutoForm (below). The function takes parameters so I can reuse it. I'm missing something obvious with UnknownObject -> Record so not sure if this is a feature request or usage issue? (Nor how to style custom components so that the background changes colour like OOTB autofields do).
const default Options = connectField<CheckboxListProps, unknown>(CheckboxList);
<AutoField name="environments" field="environments" component={Options} with={checkboxes} />
The text was updated successfully, but these errors were encountered: