Sha256: 67809f7b80710392e7146c0798cff6fb4dd091f6a108ac4e5ccaef912c6c8ddd

Contents?: true

Size: 600 Bytes

Versions: 11

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true
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

11 entries across 11 versions & 1 rubygems

Version Path
simple_form-5.3.0 lib/simple_form/components/readonly.rb
simple_form-5.2.0 lib/simple_form/components/readonly.rb
simple_form-5.1.0 lib/simple_form/components/readonly.rb
simple_form-5.0.3 lib/simple_form/components/readonly.rb
simple_form-5.0.2 lib/simple_form/components/readonly.rb
simple_form-5.0.1 lib/simple_form/components/readonly.rb
simple_form-5.0.0 lib/simple_form/components/readonly.rb
simple_form-4.1.0 lib/simple_form/components/readonly.rb
simple_form-4.0.1 lib/simple_form/components/readonly.rb
simple_form-4.0.0 lib/simple_form/components/readonly.rb
simple_form-3.5.1 lib/simple_form/components/readonly.rb