vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
2.29k stars 81 forks source link

feat: add new select options label value #18

Closed darkterminal closed 11 months ago

darkterminal commented 11 months ago

Related issue: #11

I add new support for new field type options like:

// Form Schema
country: z.string().optional()

// fieldConfig
country: {
  fieldType: 'options', // <-- options type
  options: [
    { label: "USA", value: "USA" },
    { label: "Canada", value: "Canada" },
    { label: "UK", value: "UK" },
    { label: "Australia", value: "Australia" }
  ],
}

I also add a usage example in BasicForm.tsx. Have a good freestyle punk!

vantezzen commented 11 months ago

Thank you for your contribution! It looks like your implementation broke the custom renderParent feature and I think it might be better to integrate with the existing enum/select support to stay on a DSL -> DSL level so I tweaked your PR

darkterminal commented 11 months ago

Yup... thank you.