Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Validation Errors on existing unmodified CondensedInlinePanels on save #60

@glitchwolfe

Description

@glitchwolfe

Version Info

Wagtail: 2.5.1
Django: 2.0
Python: 3.4 & 3.6 (Two different environments)
CondensedInlinePanel: 0.5.2

The Issue:

I have a CondensedInlinePanel in my page model that contains two select inputs. They save just fine on page creation, but if I go to edit the page, all unmodified panels will throw validation errors on those input fields.

In this screenshot, I just tried to add "Edited Panel" to an existing page ("The page could not be saved due to validation errors."):

CondensedInlinePanel Validation Errors

Here are the fields that are throwing errors ("Select a valid choice. ['*'] is not one of the available choices."). Note that all of the selected options are valid choices:

CondensedInlinePanel Validation Errors - Select a valid choice. ['*'] is not one of the available choices.

The Workaround:

Currently I can prevent the validation errors from occurring by manually opening each panel so the plugin marks them as "modified". Since we're using JQuery on our site I added this code to do the same thing automatically on page load. Obviously this isn't ideal, but it does work well enough for our purposes:

$('document').ready(function(){
	$('.condensed-inline-panel__action-edit').click();
	setTimeout(function(){
		$('.condensed-inline-panel__action-close').click();
	}, 300);
});

Relevant model code

class MyCondensedInlinePanelModel(Orderable):
	parent_page = ParentalKey('MyPageModel', related_name='my_panel', on_delete=models.CASCADE)

	# ...	

	DATE_TYPES = (
		('posted',   'Posted on <Date>'),
		('launched', 'Launched on <Date>'),
		('updated',  'Updated on <Date>'),
	)
	date_type = models.CharField(max_length=12, choices=DATE_TYPES, default='posted')

	TEXT_COLORS = (
		('light', 'Light Text'),
		('dark',  'Dark Text')
	)
	text_color = models.CharField(max_length=12, choices=TEXT_COLORS, default='light')

	# ...

	panels = [
		# ...
		FieldPanel('text_color'),
		MultiFieldPanel([
			FieldPanel('date_type'),
			# ...
		], heading="Post Date"),
		# ...
	]

	# ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions