Hello!
I want to create a custom input that will not render as an input html element.
so instead of having something render like this
<div >
<input> VALUE </input>
</div>
i want simple form to render like this
<div>
<span> VALUE </span>
</div>
notice there is no input tag.
The reason for this is that i want to use the form to display the values - that need to be calculated in the backend and thus are protected from mass-assignment using attr_accesible - without rendering them inside an input field that would be POSTed to the backend and trigger a mass-assignment error in Rails
i am looking at the custom inputs reference in the docs and i see
class CurrencyInput < SimpleForm::Inputs::Base
def input
"$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe
end
end
i would like to do something like
class NoInput < SimpleForm::Inputs::Base
def input
"<span>#{@builder.attribute_value}</span>".html_safe
end
end
and use it like this
f.input :my_mass_assignment_protected_field, :as => :no
Could this be done?
thanks