Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation fails or data is lost on save since 3.3 #5710

Closed
klickreflex opened this issue Mar 31, 2022 · 6 comments
Closed

Validation fails or data is lost on save since 3.3 #5710

klickreflex opened this issue Mar 31, 2022 · 6 comments
Assignees

Comments

@klickreflex
Copy link

klickreflex commented Mar 31, 2022

Bug description

I have this odd behavior that prevents me from upgrading a project to 3.3

Here's a short screen recording where I show the issue:
https://www.loom.com/share/39bd37df53ef4c14b7f30b55468d28d1

A text field with a required validation throws a validation error:

  • despite text being present.
  • the error only appears when I first focus and change some other fields inside a replicator (without adding any real changes, I can just write a single character and remove it a again)

When I remove the required validation from said field I can save the page, however the field is now emptied upon saving. This kinda explains why the validation fails: it seems the field is being pruned before validation happens.

Of course this makes me nervous for multiple reasons

  • can't upgrade the site
  • don't know where else I might lose content on save (i.e. fields that are not required)

How to reproduce

Unfortunately I'm having a hard time making this reproduceable.

Logs

No response

Versions

Statamic 3.3.4 Pro
Laravel 9.6.0
PHP 8.0.16
doublethreedigital/duplicator 2.1.1
goldnead/statamic-toc 1.1.0

Installation

Starter Kit using via CLI

Antlers Parser

regex (default)

Additional details

  • Happens since 3.3.x, on 3.2.x everything is fine
  • Happens locally on Valet as well as on a staging server provisioned with Forge, both php 8.0
  • Happens with Laravel 8 and 9
  • I have a lot of JS errors from vue.common.prod (log), but those where there with Statamic 3.2, too
  • Cleared all app caches and browser caches multiple times
@klickreflex klickreflex changed the title Validation fails or data is lost since 3.3 Validation fails or data is lost on save since 3.3 Mar 31, 2022
@klickreflex
Copy link
Author

klickreflex commented Mar 31, 2022

Here are the blueprints of the collection and some of the imported fields

Collection Blueprint

title: 'Angebot Prävention'
sections:
  main:
    display: Hauptteil
    fields:
      -
        handle: title
        field:
          type: text
          required: true
          validate:
            - required
          localizable: true
      -
        import: page_header
      -
        import: page_heading
      -
        import: page_builder
  seo:
    display: SEO
    fields:
      -
        import: seo
  sidebar:
    display: Sidebar
    fields:
      -
        handle: meta
        field:
          display: Meta
          type: section
          icon: section
          instructions: 'This entry''s meta data.'
          listable: hidden
          instructions_position: above
      -
        handle: slug
        field:
          type: slug
          required: true
          localizable: true
          validate:
            - required
      -
        handle: parent
        field:
          type: entries
          collections:
            - pages
          max_items: 1
          listable: false
          localizable: true

page_header fieldset

title: 'Page Header'
fields:
  -
    handle: page_hero
    field:
      mode: list
      container: assets
      restrict: false
      allow_uploads: true
      show_filename: true
      max_files: 1
      display: Bild
      type: assets
      icon: assets
      listable: hidden
      instructions_position: above

page_heading fieldset

title: 'Page Heading'
fields:
  -
    handle: main_heading
    field:
      input_type: text
      antlers: false
      display: Hauptüberschrift
      type: text
      icon: text
      listable: hidden
      instructions_position: above
      validate:
        - required
      localizable: true
  -
    handle: small_heading
    field:
      default: false
      display: 'Kleine Hauptüberschrift'
      type: toggle
      icon: toggle
      instructions: 'Längere Überschriften sehen besser aus wenn sie etwas kleiner dargestellt werden.'
      listable: hidden
      instructions_position: above
  -
    handle: sub_heading
    field:
      input_type: text
      antlers: false
      display: Subline
      type: text
      icon: text
      listable: hidden
      instructions_position: above
      localizable: true
  -
    handle: subline_script
    field:
      default: false
      display: 'Subline im Handschrift-Stil'
      type: toggle
      icon: toggle
      instructions: 'Der Handschrift-Stil eigenet sich nur für kurze Sublines'
      listable: hidden
      instructions_position: above
      replicator_preview: false

page_builder fieldset

title: 'Page Builder'
fields:
  -
    handle: page_builder
    field:
      type: replicator
      localizable: true
      collapse: true
      listable: false
      display: 'Page builder'
      instructions: 'Build your page by using various predefined content models.'
      sets:
        accordion:
          display: Akkordeon
          instructions: null
          fields:
            -
              import: accordion
        article:
          display: Article
          instructions: 'Long form content, can be expaned with media like figures, video, quotes or tables.'
          fields:
            -
              import: article
        list:
          display: Aufzählungsliste
          fields:
            -
              import: list
        call_to_action:
          display: 'Call to action'
          instructions: 'Show a call to action.'
          fields:
            -
              import: call_to_action
        cards:
          display: Cards
          fields:
            -
              import: cards
        collection:
          display: Collection
          instructions: 'Show collection entries.'
          fields:
            -
              import: collection
        events_in_category:
          display: 'Veranstaltungen in Bereich'
          instructions: null
          fields:
            -
              import: events_in_category
        events_on_current_page:
          display: 'Veranstaltungen für aktuelle Seite'
          instructions: null
          fields:
            -
              import: events_on_current_page
        features:
          display: Features
          fields:
            -
              import: features
        form:
          display: Form
          instructions: 'Show a form.'
          fields:
            -
              import: form
        form_booking_individual:
          display: 'Individuelles Buchungsformular'
          instructions: null
          fields:
            -
              import: form_booking_individual
        gallery:
          display: Galerie
          fields:
            -
              import: gallery
        hero:
          display: Hero
          fields:
            -
              import: hero
        service_scope:
          display: Leistungsumfang
          instructions: 'Global definierten Leistungsumfang für HF oder BF einfügen'
          fields:
            -
              import: service_scope
        link_blocks:
          display: 'Link blocks'
          instructions: 'Show link blocks.'
          fields:
            -
              import: link_blocks
        service_scope_optional:
          display: 'Optionaler Leistungsumfang'
          fields:
            -
              import: service_scope_table_optional
        pillars:
          display: '5 Säulen'
          instructions: null
          fields:
            -
              import: pillars
        text_image:
          display: 'Text & Bild'
          fields:
            -
              import: text_image
      instructions_position: above

@klickreflex
Copy link
Author

klickreflex commented Mar 31, 2022

Thanks to @ryanmitchell's suggesion I changed the handle of the field with the validation errors and all of a sudden the issue was gone 🥳

image

Looking further I saw that I've been using the handle main_heading twice in two different fieldsets that are both being imported into the collection's blueprint. While this has always been working it's likely not something you should do and it seem like by fixing this my issue is going to be resolved.

@jasonvarga
Copy link
Member

Interesting, thanks for all the details. We'll look into this.

@jasonvarga jasonvarga self-assigned this Mar 31, 2022
@klickreflex
Copy link
Author

Interesting, thanks for all the details. We'll look into this.

Cool 👍 Let me know if I can provide any further information.

@jasonvarga
Copy link
Member

Can you upgrade? This might have been fixed by #5805 which is in 3.3.7

@klickreflex
Copy link
Author

Can you upgrade? This might have been fixed by #5805 which is in 3.3.7

I've removed all my instances of redundant field names since having the issue, so unfortunately I can't reproduce it anymore.

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

No branches or pull requests

2 participants