Class: BsReadonlyInput
- Inherits:
-
Formtastic::Inputs::StringInput
- Object
- Formtastic::Inputs::StringInput
- BsReadonlyInput
- Includes:
- ActionView::Context, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper, FontAwesome::Rails::IconHelper, FormtasticBootstrap::Inputs::Base, FormtasticBootstrap::Inputs::Base::Collections
- Defined in:
- app/input/bs_readonly_input.rb
Instance Method Summary collapse
-
#to_html ⇒ Object
Nel caso di collection si può definire con :show_hidden => [true] per stampare il campo hidden o meno con il vero valore :display_field come options quale campo usare per stampare :value_renderer => Proc da aggiungere, a cui passiamo campo, valore , se passato nulla viene renderizzato standard un p contenente il valore.
Instance Method Details
#to_html ⇒ Object
Nel caso di collection si può definire con :show_hidden => [true] per stampare il campo hidden o meno con il vero valore :display_field come options quale campo usare per stampare :value_renderer => Proc da aggiungere, a cui passiamo
campo, valore , se passato nulla viene
renderizzato standard un p contenente il valore
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/input/bs_readonly_input.rb', line 18 def to_html field_name = method show_value = object.send(method) if show_value.is_a?(ActiveRecord::Base) and ![:display_field].blank? #vuol dire che siamo in una collection show_value = show_value.send([:display_field]) field_name = input_name end if ![:value_renderer].is_a?(Proc) [:value_renderer]=Proc.new { |field, value| buff = ActiveSupport::SafeBuffer.new buff<<content_tag(:p, value, class: 'form-control-static', id: "#{field.[:id]}_container") buff } end bootstrap_wrapping do content_tag(:div, class: 'input-group date') do buff = ActiveSupport::SafeBuffer.new buff<< [:value_renderer].call(self, show_value) buff<< builder.hidden_field(field_name, ) buff end end end |