Skip to content
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

Fixes: #17796 Custom Field Choices -> Create & Add Another causes IndexError #18631

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

renatoalmeidaoliveira
Copy link
Collaborator

Fixes: #17796 Custom Field Choices -> Create & Add Another causes IndexError

  • In the current release this issue doesn't raises an Exception, but setups a wrong vaule to the form after clicking in Create & Add Another
  • The fix consists in convert the array query into a string to fit the Form field that is an CharField
  • It should be possible to change the behaiviour of prepare_cloned_fields, but IMO that may lead to unwanted collateral effects, and its leads to a more complex solution

Copy link
Collaborator

@arthanson arthanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@renatoalmeidaoliveira This fixes the issue and works, but I'm a bit uncomfortable with the code, it seems like this is patching the symptom rather than the initial problem. When we do the add-another it looks like it is getting sent in as a stringified tuple and your code here is deconstructing it. Can we look at why the add-another code is passing it in like this and can it just be made to pass it in the same as the edit case? I want to make sure we understand why this is different in the fist-place - if it can't be fixed there then can you please add a description in the PR why it is being passed in differently.

@renatoalmeidaoliveira
Copy link
Collaborator Author

@arthanson I think the "real" problem relies in the different field type between the form and the model.
The CustomFieldChoiceSetForm uses a CharField for the extra_choices fields code
While the CustomFieldChoiceSet model uses an ArrayField type for extra_choices code
Because of the type difference there must be some kind of patch that convert those types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Field Choices -> Create & Add Another causes IndexError
2 participants