Simmo
Simmo

Reputation: 1719

Can't specify a class with simple_form gem with a block

I have the following form but for some reason, I can't get the HTML class to come appear in the resulting code. The documentation suggests this should work, but they don't have an example that uses a block. I've tried a few different things but I haven't found the right answer yet. I have to use a block to get the custom data to appear with the select.

= simple_form_for([:admin, @theme]) do |f|
  = f.input :title_bar
  = f.input :apple_touch_icon_image, input_html: { class: 'imagepicker' } do
    = f.select :apple_touch_icon_image_id, Theme::AppleTouchIconImage.where(company: @company).map{ |i| [i.id, i.id, { 'data-img-src' => i.image.url(:thumbnail) }] }

= f.button :submit, class: "btn-success"

Upvotes: 0

Views: 34

Answers (1)

BroiSatse
BroiSatse

Reputation: 44675

I would try:

= f.input :apple_touch_icon_image do
  = f.select :apple_touch_icon_image_id, Theme::AppleTouchIconImage.where(company: @company).map{ |i| [i.id, i.id, { 'data-img-src' => i.image.url(:thumbnail) }] }, {}, { class: 'imagepicker' }

Upvotes: 2

Related Questions