Created
October 2, 2012 23:35
-
-
Save mriddle/3824002 to your computer and use it in GitHub Desktop.
Formtastic custom html_safe input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## html_safe_intput.rb | |
# encoding: UTF-8 | |
class HtmlSafeInput < Formtastic::Inputs::TextInput | |
# Called dynamically, via form.input :foo, :as => :html_safe | |
def to_html | |
return super if object[method].blank? | |
input_wrapping do | |
label_html << | |
object[method].html_safe | |
end | |
end | |
def input_html_options | |
{ | |
:rows => 10, | |
:class => "acml" | |
}.merge(super) | |
end | |
end | |
## something.html.haml | |
# usage | |
form.input :some_html_content, :label => 'My HTML safe content', :as => :html_safe | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment