trailblazer / formular

Form builder for Ruby. Fast, Furious, and Framework-Agnostic.
MIT License
81 stars 17 forks source link

Checkbox element is not selected when it should #41

Closed Titinux closed 7 years ago

Titinux commented 7 years ago

I'm using formular master branch

f.checkbox(:is_public)

with form object responding to is_public with true or false the checkbox is never checked. I have probably misunderstand something but I don't know what.

emaglio commented 7 years ago

You need to pass the value in order to match the checked status. For example: f.checked :is_public, value: true This will be checked only if model.is_public == true

Here a test, it's not super readable but it works.

hope this makes sense

fran-worley commented 7 years ago

Would it be sensible to have true as the default value? It's commonly used as a boolean field...

Titinux commented 7 years ago

👍 @emaglio It works great, thanks.

@fran-worley I think true would be a better default value. Documentation would have really helped on this problem. If you write a global documentation structure I would be pleased to fill it with articles about elements.

emaglio commented 7 years ago

We are working on the documents...we should have something soon!