Skip to content

Introduce decorate field option #3728

Open
@Paul-Bob

Description

@Paul-Bob

Context

The format_using option is useful for formatting the output of a field, but it applies to both display and edit views. This often requires conditional logic to ensure proper behavior in different contexts. For example:

field :item, as: :text, format_using: -> {
  view.display? ? link_to(value, record.item_link, target: "_blank") : value
}

To simplify this, lets introduce a decorate option. This would function similarly to format_using, but only apply to display views (e.g., Show and Index), keeping the edit form unaffected.

With decorate, the same behavior could be achieved more cleanly:

field :item, as: :text, decorate: -> {
  link_to(value, record.item_link, target: "_blank")
}

Metadata

Metadata

Type

No type

Projects

  • Status

    In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions