administrate-field-enum icon indicating copy to clipboard operation
administrate-field-enum copied to clipboard

Do not render i18n value of enum if data is nil

Open duduribeiro opened this issue 2 years ago • 0 comments

Currently the lib tries to render the i18n value of the field even when it is nil. The problem with this is that when you have some i18n of it like the following: matrimonial_regimes: community_property: Comunhão universal de bens partial_property: Comunhão parcial de bens separate_property: Separação de bens the lib renders all values on the page as a hash: {:community_property=>"Comunhão universal de bens", :partial_property=>"Comunhão parcial de bens", :separate_property=>"Separação de bens"}

image

This happens because the i18n key used on the view "activerecord.attributes.#{field.resource.class.name.underscore}.

will render everything on the top level of my enum translations.

This commit changes the views to not try to render if data is nil.

duduribeiro avatar May 31 '23 00:05 duduribeiro