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

Validation Errors on existing unmodified CondensedInlinePanels on save #60

Open
glitchwolfe opened this issue Sep 18, 2019 · 3 comments

Comments

@glitchwolfe
Copy link

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"),
		# ...
	]

	# ...
@myornet
Copy link

myornet commented Sep 30, 2019

I have exactly the same problem.
But if I expand each of the related items the validation is successful

@erick-otenyo
Copy link

Facing same challenge

@noampolak
Copy link

So am I
with:
Wagtail: 2.10
Django: 3.1
Python: 3.85
CondensedInlinePanel: 0.5.3

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

No branches or pull requests

4 participants