getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.39k stars 1.39k forks source link

Toggle field not remembering current state #2097

Open cabajian opened 6 years ago

cabajian commented 6 years ago

In my form.yaml file, I have the following field:

.validate.required:
    type: toggle
    highlight: true
    default: true
    options:
        true: YES
        false: NO
    validate:
        type: bool
    label: Required

and this correctly shows up in the admin panel and works with my form.md header. However, the selected option in the admin panel is overridden by the default value every time I refresh. I've tried removing default: true with no success.

How do I get the value in the admin panel to show the current state?

rhukster commented 5 years ago

This might be due to your field name .validate.required... Can you try another name such as validate_required ?

cabajian commented 5 years ago

It relates to the markup:

validate:
    required: true