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

Default values not working after saving #11355

Open
andjsch opened this issue Jan 14, 2025 · 2 comments · May be fixed by #11356
Open

Default values not working after saving #11355

andjsch opened this issue Jan 14, 2025 · 2 comments · May be fixed by #11356

Comments

@andjsch
Copy link
Contributor

andjsch commented Jan 14, 2025

Bug description

Screen.Recording.2025-01-14.at.15.48.37.mov

When having a grid fieldtype that only shows on some condition (e.g. a toggle set to true) and having set Always save to false, the Stache behaves weird after saving an entry when it comes to default values.

The default value is not shown after editing and saving an entry and setting the toggle to true again, even though the grid field hasn't been saved to the file. I would expect the default value to show once the field is shown again.

How to reproduce

Create a blueprint with the following example:

  -
    handle: has_nutrition_table
    field:
      type: toggle
      display: 'Show nutrition table'
  -
    handle: nutrition_table
    field:
      type: grid
      display: 'Nutrition table'
      default:
        -
          name: Sugar
        -
          name: Salt
      always_save: false
      if:
        has_nutrition_table: 'equals true'
      fields:
        -
          handle: name
          field:
            type: text
            display: Name
            width: 33
        -
          handle: detail
          field:
            type: text
            display: Detail
            width: 66

Create an entry and see the field showing/hiding depending on the toggle state. Now save the entry with the grid being hidden. Reload the tab and set the toggle to true. You get an empty grid, instead of the prepopulated one. I would expect it to have the default values.

Once the stache has been cleared, everything works again as expected.

Logs

No response

Environment

Environment
Application Name: Steiermarkt
Laravel Version: 11.34.2
PHP Version: 8.3.15
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: steiermarkt.test
Maintenance Mode: OFF
Timezone: Europe/Vienna
Locale: de

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / daily
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.5.15

Statamic
Addons: 5
Sites: 1
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.41.0 PRO

Statamic Addons
jonassiewertsen/statamic-livewire: 3.8.1
schantldev/shop: dev-main
studio1902/statamic-peak-browser-appearance: 3.5.0
studio1902/statamic-peak-seo: 8.17.0
studio1902/statamic-peak-tools: 6.5.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@duncanmcclean duncanmcclean changed the title [Stache] Default values not working after saving Stache: Default values not working after saving Jan 14, 2025
@duncanmcclean duncanmcclean changed the title Stache: Default values not working after saving Default values not working after saving Jan 14, 2025
@duncanmcclean
Copy link
Member

It doesn't seem related to the Stache - it fixes itself after a page refresh.

@andjsch
Copy link
Contributor Author

andjsch commented Jan 14, 2025

It doesn't seem related to the Stache - it fixes itself after a page refresh.

It didn't for me. But very cool that you could get it fixed so quickly!

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

Successfully merging a pull request may close this issue.

2 participants