administrate icon indicating copy to clipboard operation
administrate copied to clipboard

Add a way to disabled/read-only a field in forms.

Open pragatiwagh opened this issue 3 years ago • 7 comments

Sometimes we have a behavior where we want to disable or hide a particular field in form.

For instance I don't want to allow user to edit certain fields in the form, with current behavior I have to write a custom field or have a conditional handling to manage such a behavior.

pragatiwagh avatar Jul 20 '22 15:07 pragatiwagh

is that good ideal to passing the html options through Field options?

jubilee2 avatar Aug 09 '22 23:08 jubilee2

Unfortunately, at the moment there isn't a way to hide/show form fields depending on dynamic conditions.

pablobm avatar Aug 12 '22 13:08 pablobm

@pragatiwagh is this meet your requirment? https://github.com/thoughtbot/administrate/pull/1991

jubilee2 avatar Aug 16 '22 17:08 jubilee2

@jubilee2 With #1991 we can restrict what fields to be included in edit/update. What i want to achieve is have a field in edit form too but as read-only. So it user knows what it is but cannot edit it. I think this would be common behavior for many applications and would be really helpful if we could something like this with simple configuration.

pragatiwagh avatar Aug 20 '22 06:08 pragatiwagh

Understand I have this need also

jubilee2 avatar Aug 20 '22 12:08 jubilee2

https://github.com/jubilee2/administrate/commit/99f10e3317d83bac815dadf45d1e71e4091ea51b

@pablobm is this good ideal?

jubilee2 avatar Aug 20 '22 14:08 jubilee2

if think this way is good then i can create a mr but for document i am limited to do write too much,

jubilee2 avatar Sep 10 '22 01:09 jubilee2

Perhaps I didn't understand correctly. Do you want this field to be disabled for every user, or only for certain users?

If it is for every user, you could do it with a custom field instead of changing an existing one. This custom field would not have a form field in it, or it would have a form field with the disabled attribute.

However, if you want that different users can see this field differently (enabled or disabled) then that's more problematic, as Administrate doesn't support this at the moment.

pablobm avatar Sep 29 '22 14:09 pablobm

I think this is a duplicate of https://github.com/thoughtbot/administrate/issues/1862, so I'm closing it in favour of the former.

pablobm avatar Apr 07 '23 16:04 pablobm