user4827489
user4827489

Reputation:

add class with check_box in rails view

<%= f.check_box(:is_active, {checked: (@employee.is_active ? false : true) }, 0, 1) %>

but I want to add class inside this how it will be done.

I had tried it like this:

<%= f.check_box(:is_active, {checked: (@employee.is_active ? false : true) }, 0, 1, :class=> 'abcd') %>

But it gives me error.Please guide me how to do this.

Upvotes: 1

Views: 4942

Answers (3)

Prashant4224
Prashant4224

Reputation: 1601

You can use like this:

<%= f.check_box(:is_active, {checked: (@employee.is_active ? false : true) ,:class=> 'abcd'}, 0, 1) %>

Upvotes: 3

RAJ
RAJ

Reputation: 9747

Try this:

<%= f.check_box(:is_active, {checked: [email protected]_active, class: 'eula_check' }, 0, 1) %>

Upvotes: 0

IngoAlbers
IngoAlbers

Reputation: 5812

You might have to put the class inside the options hash like this:

<%= f.check_box(:is_active, { checked: (@employee.is_active ? false : true), class: 'abcd' }, 0, 1) %>

Upvotes: 0

Related Questions