railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.87k stars 2.25k forks source link

Cannot hide the select box in a `has_one` field #3667

Open vpereira opened 6 months ago

vpereira commented 6 months ago

Hello RailsAdminTeam!

I'm having some issues trying to remove the select box from a form for a model with a has_one present

I have two models:

Class Repository
  has_one :tag_filter

  edit do
   field :tag_filter do
     inline_edit false
     inline_add false
     formatted_value do
            bindings[:view].link_to 'Edit Tag Filter',
                                    bindings[:view].rails_admin.edit_path(:tag_filter, bindings[:object].tag_filter.try(:id))
     end
   end
  end
Class TagFilter
  belongs_to :repository

What I'm trying to achieve:

Screenshot from 2024-01-09 15-53-33

(just worked when passing a partial to the field, but then somehow I cannot trigger the modals correctly)

What I have today:

Screenshot from 2024-01-09 15-52-20

There is any solution for that? I want to avoid users mistakenly connecting their repository with a wrong tag_filter, but I'm not sure how to make it work.