Skip to content
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

Meta api for form fields #1111

Open
harry-whorlow opened this issue Jan 13, 2025 · 6 comments
Open

Meta api for form fields #1111

harry-whorlow opened this issue Jan 13, 2025 · 6 comments

Comments

@harry-whorlow
Copy link
Contributor

harry-whorlow commented Jan 13, 2025

Continuation from the discussion #709. Listeners are implemented, however the meta field is yet to be started.

The proposal is to have the meta data available to the field component:

(example shamelessly ripped form #709)

<form.Field
  name="foo"
  meta={({ fieldApi }) => ({
    disabled: fieldApi.form.getFieldValue('someOtherField') == null,
    ...
  })}
  // or maybe expose values directly like form.Subscribe
  meta={({ values }) => ({
    disabled: values.someOtherField == null,
    ...
  })}
>
  {(field, meta) => <Comp
    disabled={meta.disabled}
    ...

You can subscribe to the meta from the Form but its pretty handy to have it available to the Field component.

I'm happy to give this a go, I just need the go ahead from a maintainer. 🤟

@fulopkovacs
Copy link
Contributor

fulopkovacs commented Jan 19, 2025

Hey 👋 , this sounds like a great idea. Personally, I prefer the second version (less verbose and more straight-forward). Are you still ready to create a PR? If yes, then this is the "go ahead"! ☺️☺️

Edit: Just to make it easy for people who visit this discussion later, this is the second version:

  // or maybe expose values directly like form.Subscribe
  meta={({ values }) => ({
    disabled: values.someOtherField == null,
    ...
  })}

@harry-whorlow
Copy link
Contributor Author

Yeah, me too.

Absolutely, I'll start it this week, and hopefully have a PR ready by next weekend. 🫡

Thanks for the go ahead 🤘

@fulopkovacs
Copy link
Contributor

Thank you for your enthusiasm! 🙌 Feel free to ping me in the comments when the PR is ready!

@harry-whorlow
Copy link
Contributor Author

@fulopkovacs, l've left a couple questions on #1125. If you get a chance to take a look it would be appreciated 🤟

@fulopkovacs
Copy link
Contributor

@fulopkovacs, l've left a couple questions on #1125. If you get a chance to take a look it would be appreciated 🤟

Awesome, thanks for your work! I'll look at them tomorrow, this week was pretty busy...

@harry-whorlow
Copy link
Contributor Author

@fulopkovacs, no worries... thanks!

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