react-bootstrap-validation icon indicating copy to clipboard operation
react-bootstrap-validation copied to clipboard

Deep binding

Open benjamincanac opened this issue 9 years ago • 1 comments

Hi,

I was wondering if there is a way to create forms and bind inputs on complex objects.

For example let's take a complex user object :

{
  name: String,
  email: String,
  birthdate: {
    day: String,
    month: String,
    year: String
  }
}  

My form would look like this :

<Form>
  <ValidatedInput type="text" name="name" validate="required" />
  <ValidatedInput type="email" name="email" validate="required,isEmail" />
  <ValidatedInput name="birthdate.day" type="select"  validate="required">
    <option>Day</option>
   ...
  </ValidatedInput>
  ...
</Form>

However, the birthdate day input creates a"birthdate.day" key instead of an object.

Do you have an idea to do this ?

Thanks!

benjamincanac avatar Dec 04 '15 10:12 benjamincanac

Could be done modifying Form to pass values through https://www.npmjs.com/package/dot-object

impleri avatar Feb 06 '16 14:02 impleri