@@ -144,7 +144,7 @@ defmodule Backpex.Fields.HasMany do
144144 < Layout . input_label as = "span " text = { @ field_options [ :label ] } />
145145 </: label >
146146
147- < Backpex.HTML.CoreComponents . dropdown id = { "has-many-dropdown-#{ @ name } " } class = "w-full " >
147+ < Backpex.HTML.CoreComponents . dropdown id = { "has-many-dropdown-#{ @ name } " } class = "w-full " readonly = { @ readonly } >
148148 <: trigger
149149 class = { [
150150 "input block h-fit w-full p-2" ,
@@ -154,12 +154,13 @@ defmodule Backpex.Fields.HasMany do
154154 aria_labelledby = { Map . get ( assigns , :aria_labelledby ) }
155155 >
156156 < div class = "flex h-full w-full flex-wrap items-center gap-1 px-2 " >
157- < p :if = { @ selected == [ ] } class = "p-0.5 text-sm " > { @ prompt } </ p >
157+ < p :if = { @ selected == [ ] } class = { [ "p-0.5 text-sm" , @ readonly && "text-base-content/40" ] } > { @ prompt } </ p >
158158 < . badge
159159 :for = { { label , value } <- @ selected }
160160 live_resource = { @ live_resource }
161161 label = { label }
162162 value = { value }
163+ readonly = { @ readonly }
163164 name = { @ name }
164165 />
165166 </ div >
@@ -302,10 +303,17 @@ defmodule Backpex.Fields.HasMany do
302303 end
303304
304305 attr :live_resource , :atom , required: true
306+ attr :readonly , :boolean , default: false
305307 attr :name , :string , required: true
306308 attr :label , :string , required: true
307309 attr :value , :string , required: true
308310
311+ defp badge ( % { readonly: true } = assigns ) do
312+ ~H"""
313+ < span class = "badge badge-sm badge-soft " > { @ label } </ span >
314+ """
315+ end
316+
309317 defp badge ( assigns ) do
310318 ~H"""
311319 < div class = "badge badge-sm badge-soft badge-primary pointer-events-auto pr-0 " >
0 commit comments