collection_radio_buttons: modify text_method

44 views
Skip to first unread message

Serguei Cambour

unread,
Oct 26, 2016, 7:11:57 AM10/26/16
to SimpleForm
is it possible to call a custom view method instead of text_method in the following example:

= f.collection_radio_buttons :answer_ids, @question.answers, :id, :text



What I'd like to do is just to sanitize the values sent by :text method. How is it possible ?

Thank you.

Serguei Cambour

unread,
Oct 27, 2016, 8:27:51 AM10/27/16
to SimpleForm
I figured out how to achieve that:

<%= f.collection_radio_buttons :name, [[true, 'H<sub>2</sub>O'] ,[false, 'SO<sub>2</sub>']], :first, :last do |b| %>
   
<%= b.label {b.radio_button + sanitize(b.text, tags: %w(sub sup))}%>
<%end%>


Hope this helps.
Reply all
Reply to author
Forward
0 new messages