8000 [Feature]: ValidatedForm wrapper · Issue #437 · airjp73/rvf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature]: ValidatedForm wrapper #437

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

Open
mschipperheyn opened this issue May 9, 2025 · 3 comments
Open

[Feature]: ValidatedForm wrapper #437

mschipperheyn opened this issue May 9, 2025 · 3 comments

Comments

@mschipperheyn
Copy link

What is the new or updated feature that you are suggesting?

I'm wondering if anyone spent the time writing a wrapper for ValidatedForm. We are on the "old" version and have a lot of forms. So migrating to the new is A LOT of work. Ideally, we would want a migration path where the old api wraps the new. I wonder if anyone did that or if it's at all viable. We might have to spend the time to do it ourselves.

Why should this feature be included?

To ease the pain of migrating to a completely new api

@airjp73
Copy link
Owner
airjp73 commented May 9, 2025

Hi!

I'd love to hear more about what specific APIs are giving you trouble. If there's something we can add to make it easier, I'm happy to do it.

In case any of this helps, here are a couple clarifications that might not be clear from the docs in their current state:

A lot of old forms might still work

Even though the new documentation highlights the new APIs as the new recommendations, a lot of simple forms can translate over directly without changes. For example, if your form looks like this:

<ValidatedForm
  validator={myValidator}
  method="post"
  id="myFormId"
>
  <MyInputField name="name" />
</ValidatedForm>

It should work as-is just by updating your imports in the form and MyInputField to reference the new package (assuming MyInputField just uses useField).

Then new and old version can existing in the same codebase

Since the new version has a new package name, it an coexist with the old version.

Recipes for removed hooks

For the hooks that were removed, the migration guide has some recipes for how you can recreate them in userland: https://www.rvf-js.io/migration#deprecated-hooks

You can use @rvf/remix as a stepping stone

The docs currently only document @rvf/react-router, but there is an @rvf/remix package as well. The switch from v6 to v7 was a really minor breaking change so the remix package isn't that far behind.

@mschipperheyn
Copy link
Author

Thanks. Yeah, but the "old version" had a lot of issues, in particular with validation refreshes and controlfield initialization. We created a form wrapper library around validated form primitives (TextInput, Toggle, etc). So, migration is non trivial for us and we don't want to maintain parallel versions. What I would have liked to see is a ValidatedForm and hook wrappers based on the new version so that migration would actually be a migration to the new version with minimum refactoring and presumably solutions for the mentioned issues.

@airjp73
Copy link
Owner
airjp73 commented May 16, 2025

I don't think I'll be able to dedicate the time to writing a compat layer, but I'm happy to accept a PR for one if you end up making one.

Another thing that might help with your migration: when I migrated the test suite I updated the input primitives to be able to accept either an RVF scope or a name string. Here's an example. If you were to update your primitives to that style, then you might find that a surprising number of forms will work out-of-the-box just by updating the imports (at least for simpler forms), while also allowing you to start adopting the new patterns.

Here's an example of a test route that didn't need any changes. Migrating that test suite was definitely an exercise in "what's the least amount of code I can change for each form?". It might be worth taking a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0