Skip to content

[RFC] Add hide_if_blank field option #1903

Open
@adrianthedev

Description

@adrianthedev

Context

There are times when we use a model that can belong to multiple adapters and we have their id's in the database. But once you set an adapter to the record you don't want to see the other adapters.

This option will hide the field if the value is nil.

# Before
field :stripe_id, as: :text, visible: -> { record.stripe_id.present? }
field :paddle_id, as: :text, visible: -> { record.paddle_id.present? }
field :braintree_id, as: :text, visible: -> { record.braintree_id.present? }

# After
field :stripe_id, as: :text, hide_if_blank: :all
field :paddle_id, as: :text, hide_if_blank: :all
field :braintree_id, as: :text, hide_if_blank: :all

The hide_if_blank option will take the view in which to be applied if the condition is valid. It can be one of the following: :index, :show, :edit, :new, :forms, :display, :all.

System configuration

Avo version: Avo 3 and up

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Triage

    Status

    Proposed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions