psaia / react-serial-forms

A lightweight and extendable SSR-friendly form library (for React).
167 stars 18 forks source link

Complex Forms #29

Closed enyachoke closed 8 years ago

enyachoke commented 8 years ago

Thanks for fixing the date issue. We are building some pretty complex dynamic json based forms. There are cases where we need some pretty complex form handling which is the reason we want to use something like serial forms since it gives a good base to build on. Cross-field validations A good example is for password confirmation currently I use a custom validator on the confirmation field which works great but when I go back and modify the password I want the the password confirmation to revalidate. So is there a way to manually trigger validation on a field or the entire form. Hiding and Showing Fields We want to able to conditionally hide and show fields based on other fields/state of serialized data. (Some advice on how best to go about this). Manipulating Fields We also need to manipulate field values from code. For example I want to set the value of a field when a user clicks a button(Also looking advise on this too) Some of this questions may be obvious but we are trying to move from angular so react is pretty new.

psaia commented 8 years ago

I can work on providing examples on how to accomplish these next week. I believe they would make great demos. For now, I can say that providing "short cuts" for these techniques in the core of Serial Forms would be out of scope since you can handle them easily using just React and controlled inputs.

ageInput() { // Only expose age if over 21.
  if (this.state.age < 21) {
    return;
  }
  return <Input ... >;
}
render() {
  return (
    <Form>
      {this.ageInput()}
    </Form>
  );
}
enyachoke commented 8 years ago

Examples or pointers will be great I don't intend to have them in the core library because not many people will really need them anyway.

psaia commented 8 years ago

Please see #32. Sorry!