-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[ui-v2] Schema form component #17166
base: main
Are you sure you want to change the base?
Conversation
```tsx | ||
import { SchemaForm } from "@/components/schemas"; | ||
|
||
const [values, setValues] = useState({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a dumb question, but what do we do with the values being set from the schema?
Is it supposed to fit in for an API request? etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using this form to create things like blocks and flow runs the endpoint to create that entity needs a record/dictionary of the values for it. For example when creating a flow run the endpoint asks for parameters
as part of the payload. If a form is created from the deployment's parameter schema, the values from the form are what you would post as the parameters of the flow run being created.
Lets chat about that more if you have any questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very awesome job!
I like how easy it looks to use.
Only have a few comments due to my lack of understanding of how "as an OSS contributor", I would be using this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit thing!
Schema Forms
Prefect uses schema generated forms for several features:
Example form
Validation
Validation of values is done on the server side. The form will return errors that can be displayed to the user. To validate the values, use the
validateSchemaValues
function.Types
The schema form uses the
PrefectSchemaObject
type to define the schema.Prefect Kind Values
A value can dictate the type of input that is rendered by using the
__prefect_kind
property. Using this property, the form will know how to render the value. For this example a json input will be rendered rather than the default object input.Default Values
By default, the form will use the
default
property to set the initial value of all fields when the form is rendered. In this example, the name field will be pre-filled with "John Doe" because the values object has no name property.