Redwood: CoercedValues function in web/form breaks forms that include any direct child node without props

Created on 11 Jul 2020  路  8Comments  路  Source: redwoodjs/redwood

https://github.com/redwoodjs/redwood/blob/96be36ab705ae5f7ec30262e2167e7bcb8ce4a87/packages/web/src/form/form.js#L190

This line is passing in direct children of <Form /> to the coercedValues function. If any of these elements are not Inputs with name props, the form throws an error onSubmit.

To replicate, create a Redwood form that includes any direct children other than RW Inputs:

<Form onSubmit={onSubmit}>
  <p>Some text</p>
  <div className="field">
    <TextField name="email" />
  </div>
</Form>

and submit =>

Uncaught (in promise) TypeError: Cannot read property 'props' of null
    at form.js:186
    at Array.forEach (<anonymous>)
    at coerceValues (form.js:183)
    at form.js:221
    at react-hook-form.es.js:1215

Screen Shot 2020-07-11 at 1 23 51 AM

bu2-confirmed forms

All 8 comments

I'll take a look at this as soon as I can

I have a unittest that triggers this bug now; tbc

@Tobbe Hey there. I put together some ideas for how we might be able to solve this over on my forked repo: https://github.com/Terris/redwood/pull/1

In a nutshell, I'm using the event api to target and iterate over the forms fields and to match field attributes with the proper function. I'm not sure it's what you were originally going for, this is just some possible ideas. Thanks for helping me with this!

@Terris I made a PR, can you please have a look?

Fix: #834

Hi gents! Thanks so much for collaborating on this -- I'd like to help make sure a fix is merged before our next release. Is this the current status:

??

Please confirm and I鈥檒l help get Rob's eye's on this asap.

馃殌

In favor of using this ==> #834

Yes, correct.

In favor of using this ==> #834

Agreed 馃憤

Was this page helpful?
0 / 5 - 0 ratings