Pass option to Field::HasOne to only display specific columns
- What would you like to be able to do? Can you provide some examples?
Let's say I have a Program has_one Product as: :item
where Product handles polymorphic association with item_type
and item_id
column.
In my Program dashboard, I want to make product editable :
ATTRIBUTE_TYPES = {
product: Field::HasOne,
}
SHOW_PAGE_ATTRIBUTES = %i[
product
]
FORM_ATTRIBUTES = %i[
product
]
In the administrate UI you end up with on program#show :

and on program#edit :

On both page the item field from Product
is visible or editable, but in that case it doesn't make sense to show or edit the item column because I am already on the page of the resource I want to edit.
- How could we go about implementing that?
Is there an option I can pass to Field::HasOne to tell it to display only certain fields ? Something like : product: Field::HasOne.with_options(except: %i[ item_type item_id])
- Can you think of other approaches to the problem?