Allow ListEditWidget to properly handle data when the widget is not rendered

Review Request #12346 — Created June 9, 2022 and submitted — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

When retrieving the value of a field from a submitted form, ListEditWidget
relies on certain special keys to be present in the form's data in order to
retrieve the value for the field. These keys are properly set when the widget is
rendered, but are not set in scenarios where the widget is not rendered (such as
in an API call posting to a form that uses this widget, or in test cases where a
form object is built without being rendered). This change allows
ListEditWidget to properly retrieve the value of a field even when the special
keys are missing.

This change also adds a deprecation warning for when the legacy behavior is used
(passing a string to the widget instead of a list). This change also prevents
the ListEdit fields from raising a ValueError when being passed null values.

  • Ran Unit tests for ListEditWidget, ListEditField and
    ListEditDictionaryField.
  • Ran all Javascript Unit tests.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4

Commits

First Last Summary ID Author
Allow ListEditWidget to properly handle data when the widget is not rendered
8d14fd4636c0f98a558c3caed782771cae6a9e2d Michelle Aubin
djblets/forms/fields.py
djblets/forms/widgets.py
djblets/forms/tests/test_list_edit_dictionary_field.py
djblets/forms/tests/test_list_edit_field.py
djblets/forms/tests/test_list_edit_widget.py
Loading...