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

How to avoid the first select option overrides corresponding frontmatter field content, thanks

Solved by Jose View solution

Started by Jose 1 year ago · 1 replies · 52 views
1 year ago

Hello

I have a blueprint for the Grav admin module, so the user can enter the right information into the frontmatter. With the text field, the corresponding tab takes the related value from the frontmatter field that corresponds and places it in its place inside the field of the editing form. But the select field does not work this way, and each time I save a page the default of the select overrides the corresponding already existing frontmatter field data.
For example:

YAML
               header.property.type:
                  type: select
                  label: THEME_QUARKCUSTOM.PROPERTY.TYPE
                  help: Select the type of property
                  size: small
                  default: {{ header.property.type|raw }}
                  options:
                    Apartment: Apartment
                    House: House
                    Land: Land

Even if I set process twig first, this does not work:
default: {{ header.property.type|raw }}

In the frontmatter I have:

YAML
property:
  type: House

But when saving, the first option is Apartment, and it overrides House on the frontmatter field: type.

How can I resolve this problem of automatically setting the default of the select with what is already in the corresponding frontmatter field? Since always a new page is copied from an old page, then I can change the option or leave what it is originally in the field. But the select does not allow me to do so.
Thanks for any help

1 year ago Solution

Hello, I used this YAML validator and I found some issues, like a missing space after the : also a wrong reference to a frontmatter field, and I do not remember what else, now is working fine, with no additional coding, Grav is great!.
Thanks.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago