Skip to content

Conversation

@DanSheps
Copy link
Member

Fixes: #17794 - Setup get_field_value to return multiple values in the event of multi-values passed in a modelmultiplechoice or multiplechoice field.

  • Edit tests
  • Edit get_field_value to return multiple values in the event of a Multi-Value field being passed

@DanSheps DanSheps self-assigned this Apr 15, 2025
@DanSheps DanSheps requested review from a team and jeremystretch and removed request for a team April 28, 2025 13:08
@DanSheps DanSheps marked this pull request as ready for review April 28, 2025 13:08
@DanSheps
Copy link
Member Author

A note, I could rewrite this to use a new function, get_field_values() in the case of form fields with MultipleChoice fields. This seemed like the path of least resistance.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

I wasn't able to reproduce the original issue. Could you please update #17794 with complete reproduction steps?

@DanSheps
Copy link
Member Author

Yeah, I can do that, however, it isn't really something reproducable without editing our code.

The reason for this, after diving into it, is this was originally blocking #17211 as I originally wanted to do:

        tagged_vlans = get_field_value(self, 'tagged_vlans') if 'tagged_vlans' in self.fields.keys() else []

in the clean() on dcim/forms/common.py (line 46) however to not have it blocked, we instead did:

        if 'tagged_vlans' in self.fields.keys():
            tagged_vlans = self.cleaned_data.get('tagged_vlans') if self.is_bound else \
                self.get_initial_for_field(self.fields['tagged_vlans'], 'tagged_vlans')
        else:
            tagged_vlans = []

This would still help as it would clean up this logic slightly I suppose but I think this could also be closed out if we deem it not required.

@DanSheps DanSheps closed this May 15, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Utility function get_field_value returns last value when used on a multi-value field

3 participants