@@ -149,11 +149,6 @@ defmodule Backpex.Field do
149
149
"""
150
150
@ callback render_index_form ( assigns :: map ( ) ) :: % Phoenix.LiveView.Rendered { }
151
151
152
- @ doc """
153
- Used to render the readonly version of the field.
154
- """
155
- @ callback render_form_readonly ( assigns :: map ( ) ) :: % Phoenix.LiveView.Rendered { }
156
-
157
152
@ doc """
158
153
The field to be displayed on index views. In most cases this is the name / key configured in the corresponding field definition.
159
154
In fields with associations this value often differs from the name / key. The function will receive the field definition.
@@ -211,7 +206,7 @@ defmodule Backpex.Field do
211
206
) ::
212
207
Ecto.Query . dynamic_expr ( )
213
208
214
- @ optional_callbacks render_form_readonly: 1 , render_index_form: 1
209
+ @ optional_callbacks render_index_form: 1
215
210
216
211
@ doc """
217
212
Returns the default config schema.
@@ -277,16 +272,9 @@ defmodule Backpex.Field do
277
272
278
273
@ impl Phoenix.LiveComponent
279
274
def render ( % { type: :form } = assigns ) do
280
- if Backpex.Field . readonly? ( assigns . field_options , assigns ) do
281
- case Map . get ( assigns . field_options , :render_form_readonly ) do
282
- nil ->
283
- apply ( __MODULE__ , :render_form_readonly , [ assigns ] )
284
-
285
- func ->
286
- func . ( assigns )
287
- end
288
- else
289
- Map . get ( assigns . field_options , :render_form , & render_form / 1 ) . ( assigns )
275
+ case Map . get ( assigns . field_options , :render_form ) do
276
+ fun when is_function ( fun , 1 ) -> fun . ( assigns )
277
+ nil -> apply ( __MODULE__ , :render_form , [ assigns ] )
290
278
end
291
279
end
292
280
0 commit comments