wagtail-deprecated / wagtail-condensedinlinepanel

Fast, drop-in replacement for Wagtail's inline panel with drag and drop
BSD 3-Clause "New" or "Revised" License
85 stars 22 forks source link

Validation Errors on existing unmodified CondensedInlinePanels on save #60

Open glitchwolfe opened 4 years ago

glitchwolfe commented 4 years ago

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 commented 4 years ago

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

erick-otenyo commented 4 years ago

Facing same challenge

noampolak commented 3 years ago

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