re-formality icon indicating copy to clipboard operation
re-formality copied to clipboard

Complex forms

Open baransu opened this issue 6 years ago • 1 comments

I'm trying to migrate plain reducer component that handles updates/validation of my form to re-formality. My form is complex and I'm having a hard time thinking about correct values/fields/updaters. Here is a type of the state:

type state = {
  name: string,
  parts: list(part)
}
and part = {
  image: string,
  title: string,
  subtitle: string,
  buttons: list(button),
}
and button =
  | UrlButton(url)
  | PluginButton(plugin)
and url = {
  id: string,
  caption: string,
  url: string,
}
and plugin = {
  caption: string,
  pluginId: string,
  instanceId: string,
};

For me, it's a really hard example. I want to have all functionality (like validation) available for even most nested values. Current API allows you to manage "one level deep" state really good but more complex state would require a lot of duplicated logic to update nested fields, a lot of fields, values etc.

Do you have any ideas on how we can improve re-formality API to better handle cases like this or how to approach this in application code using current API?

baransu avatar Oct 02 '18 21:10 baransu

This is somewhat similar to #29 and I haven't looked into complex examples yet. Can't promise anything concrete but I'll look into forms w/ complex structure sooner or later.

alex35mil avatar Oct 10 '18 13:10 alex35mil