wagtailmedia icon indicating copy to clipboard operation
wagtailmedia copied to clipboard

Add support for general `FieldPanel` with Wagtail 3.0+

Open zerolab opened this issue 2 years ago • 2 comments

References:

  • https://docs.wagtail.org/en/latest/releases/3.0.html#removal-of-special-purpose-field-panel-types
  • https://docs.wagtail.org/en/latest/releases/3.0.html#api-changes-to-panels-edithandlers
  • https://docs.wagtail.org/en/latest/extending/forms.html#defining-admin-form-widgets

Where possible, third-party packages that implement their own field panel types should be updated to allow using a plain FieldPanel instead, in line with Wagtail dropping its own special-purpose field panel types such as StreamFieldPanel and ImageChooserPanel. The steps for doing this will depend on the package’s functionality, but in general:

  • If the panel sets a custom template, your code should instead define a Widget class that produces your desired HTML rendering.
  • If the panel provides a widget_overrides method, your code should instead call register_form_field_override so that the desired widget is always selected for the relevant model field type.
  • If the panel provides a get_comparison_class method, your code should instead call wagtail.admin.compare.register_comparison_class to register the comparison class against the relevant model field type.

Fix deprecations too:

deprecations
tests/test_edit_handlers.py:202: RemovedInWagtail50Warning: The MediaChooserPanel.bind_to() method has been replaced by bind_to_model(model) and get_bound_panel(instance=instance, request=request, form=form)
  media_chooser_panel = self.my_media_chooser_panel.bind_to(
/home/runner/work/wagtailmedia/wagtailmedia/tests/test_edit_handlers.py:205: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  result = media_chooser_panel.render_as_field()
tests/test_edit_handlers.py:143: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  result = self.media_chooser_panel.render_as_field()
tests/test_edit_handlers.py:172: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  result = media_chooser_panel.render_as_field()
tests/test_edit_handlers.py:248: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  media_chooser_panel.render_as_field(),
tests/test_edit_handlers.py:121: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  self.media_chooser_panel.render_as_field(),
tests/test_edit_handlers.py:130: RemovedInWagtail50Warning: Panel.render_as_field is deprecated. Use render_html instead
  media_chooser_panel.render_as_field(),

zerolab avatar Apr 10 '22 15:04 zerolab

This got done, right?

Scotchester avatar Nov 21 '22 18:11 Scotchester

Not to my knowledge. Chances are things just work for MediaChooserPanel.

zerolab avatar Nov 22 '22 18:11 zerolab