Enctype should be set when file upload input is used
I'm using formular master branch
form(model, path) do
f.input :image, type: :file
end
When using input element with type: :file, enctype="multipart/form-data" should be added to the form tag.
Formular is not doing any magic, that's why you have to add the enctype="multipart/form-data" as argument in your form:
form(model,url,enctype="multipart/form-data")
At least this is how I interpretate Formular, sometimes is a bit complicated but at least you have the control on what's going on!
Maybe Fran has a different opinion on that
My opinion is that Formular should be clever but let you use elementary bricks if you want to. After it's all about to trace a line between cleverness and black magic. simple_form goes way too far but I'm about to finish converting my application from simple_form to formular and my forms are far more complex than before.
My personal line 😄 cleverness
- add hidden input to cover the case where unchecked checkbox value is not send
- enctype="multipart/form-data" when uploading file (you can't upload file if this isn't set)
- ...
black magic (maybe extra gems or optional code without hard dependencies can cover this)
- search into model for associations
- auto labelling with i18n
I agree with @Titinux there is little point in a form with a file input and no enctype. We already add the hidden input for checkboxes so I don't see why we shouldn't find a way to handle this.