Adding additional input to simple_form

I use the pearl simple_form.

I present a collection based entry (list of all mine actiontypes)

<%= f.association :actiontype, collection: Actiontype.all, input_html: { data: {'impacts-pnl' => ??}} %>

I would like to be able to add a data attribute to the input to store additional data.

In this case, I want to keep the attribute of impacts_pnlmine actiontype. The only problem is that I do not know how to refer to the currentactiontype

collection.impacts_pnl not working (obviously)

actiontype.impacts_pnl neither.

How can I transfer this extra bit of data to my input?

+5
source share
1 answer

- , , , , .map(). , , ;

= f.input :actiontype do
    = f.select :actiontype, Actiontype.all.map{|a| [a.name, a.id, {"data-impacts-pnl" => p.impacts_pnl}]}

. https://github.com/plataformatec/simple_form/issues/188

+14

All Articles