Sha256: aa852a2c660fb8d0c11fc7ebd8ef0097273b2152a39e21d5a3e2ec8a48304043

Contents?: true

Size: 570 Bytes

Versions: 12

Compression:

Stored size: 570 Bytes

Contents

module SimpleForm
  module Components
    # Needs to be enabled in order to do automatic lookups.
    module Readonly
      def readonly(wrapper_options = nil)
        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

12 entries across 12 versions & 3 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/components/readonly.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/components/readonly.rb
simple_form-3.4.0 lib/simple_form/components/readonly.rb
simple_form-3.3.1 lib/simple_form/components/readonly.rb
simple_form-3.3.0 lib/simple_form/components/readonly.rb
simple_form-3.2.1 lib/simple_form/components/readonly.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/simple_form-3.2.0/lib/simple_form/components/readonly.rb
simple_form-3.2.0 lib/simple_form/components/readonly.rb
simple_form-3.1.1 lib/simple_form/components/readonly.rb
simple_form-3.1.0 lib/simple_form/components/readonly.rb
simple_form-3.1.0.rc2 lib/simple_form/components/readonly.rb
simple_form-3.1.0.rc1 lib/simple_form/components/readonly.rb