Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce decorate field option #3728

Open
Paul-Bob opened this issue Mar 7, 2025 · 0 comments
Open

Introduce decorate field option #3728

Paul-Bob opened this issue Mar 7, 2025 · 0 comments
Labels
😎 Cool Developer Experience (DX) Good first issue Good for newcomers Help wanted We could use some help with this

Comments

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Mar 7, 2025

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")
}
@github-project-automation github-project-automation bot moved this to Triage in Issues Mar 7, 2025
@adrianthedev adrianthedev added Help wanted We could use some help with this Good first issue Good for newcomers Developer Experience (DX) 😎 Cool labels Mar 7, 2025
@Paul-Bob Paul-Bob moved this from Triage to To Do in Issues Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😎 Cool Developer Experience (DX) Good first issue Good for newcomers Help wanted We could use some help with this
Projects
Status: To Do
Development

No branches or pull requests

2 participants