Insert HTML on Radio Label on Formtastic
Posted
by
Adrian Matteo
on Stack Overflow
See other posts from Stack Overflow
or by Adrian Matteo
Published on 2012-08-29T02:50:44Z
Indexed on
2012/08/29
3:38 UTC
Read the original article
Hit count: 291
I have a form that has a radio button on it (Formtastic), and It works just fine with the :collection I'm passing. The problem is I want some part of the text to be affected by some CSS, but the :collection attribute does not let me put in HTML.
Here's my code:
= subscription.input :plan_type_id, :as => :radio, :label => false, :wrapper_html => {:class => "plan_type"}, :collection => { @plans[:premium_yearly][:description]+number_to_currency(@plans[:premium_yearly][:amount], :precision => 2) => @plans[:premium_yearly][:value], @plans[:premium_monthly][:description]+number_to_currency(@plans[:premium_monthly][:amount], :precision => 2) => @plans[:premium_monthly][:value] }
Has you may may see, I build the label I want to show with my @plans variable and the :collection attribute.
Is there any way I can modify the way it renders the label, I want to put some css to some part of the label.
I want something like this:
= subscription.input :plan_type_id, :as => :radio, :label => false, :wrapper_html => {:class => "plan_type"}, :collection => { @plans[:premium_yearly][:description]+'<b>'+number_to_currency(@plans[:premium_yearly][:amount], :precision => 2)+'<\\b>' => @plans[:premium_yearly][:value], @plans[:premium_monthly][:description]+'<b>'+number_to_currency(@plans[:premium_monthly][:amount], :precision => 2)+'<\\b>' => @plans[:premium_monthly][:value] }
Thanks in advanced.
© Stack Overflow or respective owner