-
I'm thoroughly impressed by the conform API's balance of simplicity and power, and I'd like to commend @edmundhung for creating this amazing tool. However, while exploring conform, I decided to put it to the test by redesigning one of my project's forms. Yet, I encountered a roadblock when attempting to implement a simple feature: swapping values between two text fields (first name and last name) with a button click without saving the entire form. I initially thought the 'intent' section in the conform API would be a perfect solution for this task. I created an 'action,' listened for the intent, and adjusted the submission payload. To my surprise, these changes had no effect on the client-side rendered form since the payload isn't used in this context. Since my custom intent resembled conform's predefined 'list' intents, it struck me that I also might need a dual implementation – once on the server and a second time within a custom hook. To make it work both with and without JavaScript. My question is, is this dual implementation the recommended approach for custom intents, and how do you tackle similar challenges with conform? Your insights would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I am glad that you like it @lennerd! Conform now provides very limited support on custom intent button which I really want to address. As you mentioned, the dual implementation on both server and client hooks make it non trivial to introduce a custom intent. This is why I am planning to bring it a new architecture to minimize the difference between the two environments. I have a prototype working already and hopefully release it as an alpha version soon. I am still refining the solution but the general idea is to centralize form state and have the form sending it to the server so we could apply the same data manipulation similar to how we were share validation between the client and the server. Having said that, swapping values between two fields could be tricky as Conform utilize default value generally and react does not update the input value even the default value is changed. It might requires some additional support to update it through JS (which I am happy to add considering it to be a common usecase) or potentially a managed |
Beta Was this translation helpful? Give feedback.
-
This is fixed with the new update intents. Regarding v1: I wouldn't have thought its possible to improve the already great and thought full API of this library even further. This might sound over the top, but I'm just blown away by the way everything clicks into place. Great inspiration. Thanks for your great work and keep going! 👏 |
Beta Was this translation helpful? Give feedback.
This is fixed with the new update intents.
Regarding v1: I wouldn't have thought its possible to improve the already great and thought full API of this library even further. This might sound over the top, but I'm just blown away by the way everything clicks into place. Great inspiration.
Thanks for your great work and keep going! 👏