Skip to content

Instantly share code, notes, and snippets.

@mriddle
Created October 2, 2012 23:35
Show Gist options
  • Save mriddle/3824002 to your computer and use it in GitHub Desktop.
Save mriddle/3824002 to your computer and use it in GitHub Desktop.
Formtastic custom html_safe input
## 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