Skip to content

Commit

Permalink
Accessible from templates; avoids having to create new field types (#…
Browse files Browse the repository at this point in the history
…1513)

Over at #612, a fair point was
made: if field `options` were public, they could be accessed from templates.
This would enable users to customize fields without having to create new field
types, which I find a bit more cumbersome.

An argument against this change would be that it increases the contact surface
of field types, which can be an issue later if we change the interface of
fields.

An argument for this change would be that the interface of fields is unlikely to
change radically at this point. If it did, probably subclasses would have to
change anyway too, possibly forcing more significant changes than that of how to
access the options.
  • Loading branch information
pablobm committed Feb 13, 2020
1 parent 5ad65e1 commit a118f77
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/administrate/field/base.rb
Expand Up @@ -40,12 +40,10 @@ def to_partial_path
"/fields/#{self.class.field_type}/#{page}"
end

attr_reader :attribute, :data, :page, :resource
attr_reader :attribute, :data, :options, :page, :resource

protected

attr_reader :options

def self.field_type
to_s.split("::").last.underscore
end
Expand Down

0 comments on commit a118f77

Please sign in to comment.