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

AutoID changed after saving page #69

Open
frankmichel opened this issue Oct 29, 2021 · 2 comments
Open

AutoID changed after saving page #69

frankmichel opened this issue Oct 29, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@frankmichel
Copy link

frankmichel commented Oct 29, 2021

I am not sure what's going on here and if this is expected behaviour. I have a blueprint with basically the following fields configuration:

years:
  label: Years
  type: structure
  sortBy: name asc
  sortable: false
  translate: false
  fields:
    name:
      type: text
    autoid:
      type: hidden
      translate: false

events:
  label: Events
  type: structure
  sortBy: name asc
  sortable: false
  translate: false
  fields:
    name:
      type: text
    year:
      type: select
      options: query
      query:
        fetch: page.years.toStructure
        text: '{{ structureItem.name }}'
        value: '{{ structureItem.autoid }}'
    autoid:
      type: hidden
      translate: false

So basically I am using the structure years to populate the options which are available in the events structure. In reality these two structures are on two different tabs, but on the same page. And I think this is part of the problem since the blueprint example is exactly the same, but on two different pages.

Screenshot 2021-10-29 at 17 30 34

So, when I add a year to my years structure and save the page everything looks fine and the content file gets the new values with an autoid:

Screenshot 2021-10-29 at 17 31 55

However, after changing anything else on the same page and then saving the page again (without reloading) the autoid of the previously saved year will be changed behind the scenes. This causes some issues when trying to use the newly created year in the events structure on the same page. A newly created year will be available to be selected as an option, and it will look perfectly when saving the events structure.

Screenshot 2021-10-29 at 17 43 04

But after reloading the page, the year will be empty since the autoid of the year has been changed. I have no idea why the autoid is changing once it has been previously saved. Is there a way to prevent the autoid from being updated/changed once it has been saved?

Screenshot 2021-10-29 at 17 35 26

The autoid has magically changed:
Screenshot 2021-10-29 at 17 35 51

The problem will not occur whenever I do the following:

  1. add the year to the years structure
  2. save the page
  3. reload the panel
  4. add an entry with the newly added year to the events structure
  5. save the page
@bnomei bnomei self-assigned this Nov 3, 2021
@bnomei bnomei added the bug Something isn't working label Nov 3, 2021
@bnomei
Copy link
Owner

bnomei commented Nov 3, 2021

thanks for the detailed issue report. i will take a closer look asap.

does your blueprint have an autoid field at root level. like $page->autoid()?

because if i remember correctly the index depends on each page having that. otherwise it might think the page has not been indexed yet and assign new values. so maybe you can not just have autoids in structures but you need one for the page object as well. BUT i need to verify that.

@frankmichel
Copy link
Author

@bnomei Thanks for looking into it! It does have an autoid on root level. I can see it in the content folder .txt file (Autoid: osldmy9g) and I can also var_dump it in the template.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants