Selectize field in admin blueprints erases values

I am having trouble with a Selectize field in a blueprint for the Admin (configured through a theme):

  • custom values (not defined in the selectize.options) are erased in each subsequent save

This is the configuration I am using:

header.credits_people:
    type: selectize
    selectize:
        options:
            - text: "A"
              value: "Person A"
            - text: "B"
              value: "Person B"
            - text: "C"
              value: "Person C"
            - text: "D"
              value: "Person D"
            - text: "E"
              value: "Person E"
    label: People
    validate:
        type: commalist

Selectize filled BEFORE save: two values from selectize.options, six custom values, two selectize.options are not selected

AFTER first save (normal mode): first two custom values are missing

AFTER first save (expert mode): all values are still in the frontmatter
(changing from normal to expert mode without changing anything shows ‘Changes Detected’ dialog - weird!)

Saving in expert mode makes no changes to the list.

AFTER second save in normal mode: next two custom values are missing


expert mode still shows four custom values:

Each subsequent save in normal mode erases two custom values until I am left only with the three selectize.options (A, B, C).

Other things I tried:

  • if all 5 selectize.options are selected
    • custom values are entered after selectize.options → nothing is erased
    • custom values are entered before selectize.options → custom values are erased, 5 at a time
    • custom values are entered after 3 selectize.options, with 2 remaining selectize.options after them → custom values are erased, 2 at a time

Conclusion:

  • if all selectize.options are selected and lead, no custom values are erased
  • otherwise the number of custom values erased is equal to the number of selectize.options not selected or the number of selectize.options that follow the custom values

Is there a mistake in my field configuration or other setting I should have changed?
(I am currently using Grav 1.7.9)

Thanks!, and sorry for the long post :nerd_face:

@jrzav, Seems similar to this issue in Admin repo: Selectize field drops custom values after saving/refreshing input

Hopefully the proposed workaround works for you…

Thank you @pamtbaau, this is exactly my issue. Next time I’ll search in github too :grin:.

The worksround works for now, but I would like to have the option to control the order of the items.

And it would be great if selectize had the ability to add custom values to the options, so they can be used in another pages.

Should I propose adding a warning to the docs / learn site?

@jrzav,

Next time I’ll search in github too

Would have saved you quite a bit of time I guess…

If you do want to update the docs, I would suggest to only add a red/orange warning notice like:

Known issues:

1 Like

First pull request done. I hope I didn’t mess it up. Thanks!

1 Like