Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Selectize field in admin blueprints erases values

first-time

Solved by pamtbaau View solution

Started by João Ribeiro Vaz 5 years ago · 4 replies · 637 views
5 years ago

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:

YAML
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
image|690x124

AFTER first save (normal mode): first two custom values are missing
image|690x81

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!)
image|690x246

Saving in expert mode makes no changes to the list.

AFTER second save in normal mode: next two custom values are missing
image|690x71
expert mode still shows four custom values:
image|690x188

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 🤓

5 years ago

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

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?

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1140 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago