rubymonolith / superform

Build highly customizable forms in Rails
MIT License
263 stars 14 forks source link

File with ActiveStorage cause ActiveSupport::MessageVerifier::InvalidSignature without enctype #32

Closed nolantait closed 2 months ago

nolantait commented 3 months ago

Full error is:

ActiveSupport::MessageVerifier::InvalidSignature: mismatched digest

This can be fixed by adding the enctype attribute to multipart/form-data:

render Some::Form.new(@model, enctype: "multipart/form-data")

Maybe for now putting a note into the README? Can't think of an obvious way of passing this back up to the around_template call. Maybe introspecting the form in that method?

ediathome commented 3 months ago

I had the same issue last week and would also vote for mentioning it in the README

bradgessler commented 3 months ago

Does it make sense for this value to be the default? In theory it works for forms with or without files. What’s the downside to this being enabled by default?

If there is an issue enabling this by default, it might be possible to detect when a file field is used to automatically set the form to this encoding type.

Regardless, I agree this should be in the docs.

nolantait commented 3 months ago

GET based form semantics would be ruined and it would bloat the size of your requests slightly from what I can gather online.

I was thinking of flagging the field when the methods are called but it would require people implementing their own fields to call super or flag it themselves. Same problem if we just add introspection for the types as it depends on controlling the input calls.

bradgessler commented 3 months ago

Ah that would be bad if the GET semantics were ruined.

Seems like docs is the way to go.

ediathome commented 3 months ago

Just opened a PR with a potential addition to the docs