Sha256: e3f7d426ff29f3b184f528da6ae215c279ae75e69e2491656f7434cd3714ab7a

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

module Effective
  module FormBuilderInputs
    class EffectiveStaticControl < Effective::FormBuilderInput
      delegate :content_tag, :to => :@template

      def default_input_html
        {class: 'form-control-static'}
      end

      def to_html
        if value.kind_of?(String) && value.start_with?('<p>') && value.end_with?('</p>')
          content_tag(:p, value[3...-4].html_safe, tag_options)
        else
          content_tag(:p, (value.html_safe? ? value : (value.to_s || '').html_safe), tag_options)
        end

      end

      def html_options
        super.tap do |html_options|
          html_options[:class].delete('form-control')
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_form_inputs-1.5.0 app/models/effective/form_builder_inputs/effective_static_control.rb
effective_form_inputs-1.4.1 app/models/effective/form_builder_inputs/effective_static_control.rb
effective_form_inputs-1.4.0 app/models/effective/form_builder_inputs/effective_static_control.rb