Sha256: ae882d09bc5a44e4177fce13ac638f88451fe1cb2416ffdad008ecfa6f174c35

Contents?: true

Size: 547 Bytes

Versions: 18

Compression:

Stored size: 547 Bytes

Contents

module SimpleForm
  module Components
    # Needs to be enabled in order to do automatic lookups.
    module Readonly
      def readonly
        if readonly_attribute? && !has_readonly?
          input_html_options[:readonly] ||= true
          input_html_classes << :readonly
        end
        nil
      end

      private

      def readonly_attribute?
        object.class.respond_to?(:readonly_attributes) &&
          object.persisted? &&
          object.class.readonly_attributes.include?(attribute_name.to_s)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
simple_form-3.0.4 lib/simple_form/components/readonly.rb
simple_form-2.1.3 lib/simple_form/components/readonly.rb
simple_form-2.1.2 lib/simple_form/components/readonly.rb
simple_form-3.0.3 lib/simple_form/components/readonly.rb
simple_form-3.0.2 lib/simple_form/components/readonly.rb
simple_form-3.0.1 lib/simple_form/components/readonly.rb
simple_form-2.1.1 lib/simple_form/components/readonly.rb
simple_form-3.0.0 lib/simple_form/components/readonly.rb
simple_form_awesome-2.5.0 lib/simple_form/components/readonly.rb
simple_form_awesome-2.4.0 lib/simple_form/components/readonly.rb
simple_form_awesome-2.3.0 lib/simple_form/components/readonly.rb
simple_form_awesome-2.2.0 lib/simple_form/components/readonly.rb
simple_form-3.0.0.rc lib/simple_form/components/readonly.rb
simple_form-2.1.0 lib/simple_form/components/readonly.rb
simple_form-3.0.0.beta1 lib/simple_form/components/readonly.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/simple_form-2.0.4/lib/simple_form/components/readonly.rb
simple_form-2.0.4 lib/simple_form/components/readonly.rb
simple_form-2.0.3 lib/simple_form/components/readonly.rb