module SimpleForm::Components::Readonly

Needs to be enabled in order to do automatic lookups.

Public Instance Methods

readonly() click to toggle source
# File lib/simple_form/components/readonly.rb, line 5
def readonly
  if readonly_attribute? && !has_readonly?
    input_html_options[:readonly] ||= true
    input_html_classes << :readonly
  end
  nil
end

Private Instance Methods

readonly_attribute?() click to toggle source
# File lib/simple_form/components/readonly.rb, line 15
def readonly_attribute?
  object.class.respond_to?(:readonly_attributes) &&
    object.persisted? &&
    object.class.readonly_attributes.include?(attribute_name.to_s)
end