django-enumfield icon indicating copy to clipboard operation
django-enumfield copied to clipboard

disabled field fills wrong initial value

Open fboerman opened this issue 4 years ago • 4 comments

Hi, I have an enumfield that I have disabled as part of a form with disabled=True. however then the validation always validates the field as being wrong.

After some debugging I found this is due to the fact that the value given to clean differs if the field is disabled or not. when it is not disabled it is a string containing a number if it is disabled it is a string containing the string name of the enum option.

I have spend quite some time thinking about a solution myself but cant get it right. Does any of the maintainers have an idea? Thanks in advance!

fboerman avatar Oct 06 '20 19:10 fboerman

About a year too late but ... 😅 Did you forget to set the field to required=False? I get an empty string when I disable the field + set required to false (which is intended behavior as far as I can tell.)

The form validates.

ghost avatar Nov 05 '21 00:11 ghost

This seems like it shouldn't be open anymore, close it?

Mojken avatar Nov 11 '21 09:11 Mojken

About a year too late but ... sweat_smile Did you forget to set the field to required=False? I get an empty string when I disable the field + set required to false (which is intended behavior as far as I can tell.)

The form validates.

do you mean explicitely setting it instead of leaving it open as the default?

fboerman avatar Nov 13 '21 15:11 fboerman

I mean explicitly setting required=False in the form class.

ghost avatar Nov 19 '21 16:11 ghost