Google Groups

Re: Checkbox inline for different db fields


Carlos Antonio da Silva Apr 24, 2012 12:17 PM
Posted in group: SimpleForm
That's weird.. perhaps you could try adding some example to the https://github.com/rafaelfranca/simple_form-bootstrap app, so we can play with and see were we go?

-- 
At.
Carlos Antonio

On Tuesday, April 24, 2012 at 3:59 PM, Fernando Shayani wrote:

Hi Carlos,

I tried the solution, but didn't work. The output was all messy.


Em 21/04/2012, às 19:29, Carlos Antonio da Silva escreveu:

Hey Fernando,

have you tried the solutions we've discussing in the issue? Did it work? 
I'll link here for future reference: https://github.com/plataformatec/simple_form/issues/538

If it is not working for you yet, we can try to figure out another solution.

-- 
At.
Carlos Antonio

On Friday, April 13, 2012 at 10:00 AM, Fernando Shayani wrote:

Hi all. I posted this question in the GitHut site but I'll also post
here. Any help will be useful :)

I'm having some trouble to create a group of checkboxes with
simple_form and bootstrap.

I have 3 fields in the database that are booleans: option1, option2
and option3. I need to create a checkbox group inline like this:

SELECT YOUR OPTIONS: [ ] Option 1 [ ] Option 2 [ ] Option 3
Rails is expecting to send the fields as independent fields, like
"tablename[option1]" , "tablename[option2]" and "tablename[option3]".

If I use the

f.input :option, :collection => [[true, '1'] ,[true, '2'],[true,
'3']], :as => :check_boxes

, the html markup will be messed up.

I'm looking for a way so the markup will something like:

<input name="tablename[option1]" type="hidden" value="0">
<input name="tablename[option2]" type="hidden" value="0">
<input name="tablename[option3]" type="hidden" value="0">

If I just use the

f.input :option1
f.input :option2
f.input :option3

the checkboxes will be vertical and will not be "grouped".

Any ideas?