-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form templatetags: raise exceptions when unable to infer an enum #1540
Comments
Presumably, Unknown is only an option for NullBoolean fields? For choice fields, it appears that |
At the moment we just save the display part of the string because tbh that's just the only usecase we could conceive of wanting. So this will require some yes please for the None/Unknown plan. |
Where a field is a BooleanField or a NullBooleanField inference should generate a lookup list with `[Yes, No]` and `[Yes, No, Unknown]` as options (for radio buttons). This will require changes to templates/radio.html so that Unkown does not use Unknown as a value, instead leaving the value empty so that we know the intended value is None. This would be easier if lookuplists were tuples (like choices in Django) so I'm considering implementing support for lists of tuples (as well as the current list of strings) for lookuplists - the alternative is too much logic in the template and special-casing the string 'Unknown' Will fix #1540
I think we need to rethink this. There are 2 options. Move logic into the field translator and do a hard coded if field type == Boolean or NullBoolean then translate yes, no, unknown accordingly. Use logic similar to what is included here but change it so that we use a dictionary which populates value. I'm pro the latter as it doesn't require angular. The problem is any instances where we have hardcoded lookup list properties that currently takes a string that we include as javascript in the template. Its an interesting one, but lets hold off for the time being. |
Opal form templatetags attempt to infer enums. They look at Django Choices, Opal Lookuplists or arbitrary JSON passed in the template.
Two enhancements would improve this functionality:
The text was updated successfully, but these errors were encountered: