reusable form field components
Hi everyone, I'm using TanStack Form with SolidJS, and I'm trying to extract some reusable form field components so I can use them across different forms more easily.
For example, I have different data types like weapon, armor, and pet. Each of them has their own specific fields, but also shares some common fields like id, statistic, createdAt, updatedAt, etc.
I'd like to extract these common fields into a shared form component. I'm currently trying to write a component that accepts the form object as a prop, but the FormApi type is really hard to write due to the large number of generic parameters.
Do you have any suggestions on how to handle this pattern more cleanly? Especially around typing the form prop and making reusable field blocks?
Thanks!
5 Replies
flat-fuchsia•3mo ago
Form composition is currently in the works for Solidjs. Follow it here https://github.com/TanStack/form/pull/1453
Solid users are few and far between, so any feedback / criticism is greatly appreciated!
GitHub
[Solid.js] feat: add withForm and createAppForm APIs by crutchcorn ...
TODOs
Write docs
Receive code review from community to validate if useFieldContext should return a signal or stay as-is
flat-fuchsia•3mo ago
especially for the signal in
useFieldContext
as for field blocks, that is currently being tracked in a different PR which is React only at the moment. However, if the linked PR gets merged and feedback is collected, it can then be used to implement the field groupsadverse-sapphireOP•3mo ago
OK, thank you very much
stormy-gold•2mo ago
Hey
I did some work on another PR and got it working.
You can try it out by installing my PR, feedback is welcome.
adverse-sapphireOP•2mo ago
Thanks, let me research how to do it.