avo-hq / docs.avohq.io

Documentation website for Avo
https://docs.avohq.io/
3 stars 58 forks source link

`dash_if_blank` on custom fields without a direct attribute on the model #308

Open Paul-Bob opened 2 weeks ago

Paul-Bob commented 2 weeks ago

Add a link to dash_if_blank documentation page on the custom fields page. When defining a custom field like field :map, as: :my_map_custom_field, and the model lacks a map attribute (for instance, using separate latitude and longitude fields instead), the component renders a dash because no value exists for map.

This behavior can be confusing if not clearly documented, as users might not expect a dash to appear in place whatever he does on the component.

This renders a dash:

<%= field_wrapper **field_wrapper_args do %>
    hello
<% end %>

This renders "hello"

<%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
    hello
<% end %>
Paul-Bob commented 2 weeks ago

Discord discussion that originated this idea https://discord.com/channels/740892036978442260/1138182212655788054/1304111311084326953