getgrav / grav-plugin-form

Grav Form Plugin
http://getgrav.org
MIT License
53 stars 79 forks source link

Select Field not saving in plugin options in admin #553

Closed jgonyea closed 2 years ago

jgonyea commented 2 years ago

tl;dr: Select form field saving is broken if multiple is set

I'm attempting to add a multiple select to my plugin configuration blueprints.yaml file. In my file, I add the following:

    page_types:
      type: select
      size: long
      classes: fancy
      label: 'Page Types'
      help: 'Page types to be considered as assignable to group content.  Has CRUD implications for selected content.'
      options:
        default: 'Default - based on folder name'
        folder: 'Folder - based on prefix-less folder name'
        title: 'Title - based on title field in header'
        date: 'Date - based on date field in header'
      multiple: true
      validate.type: array

as a sibling of enabled. Viewing the admin configuration of the plugin displays the select field as expected, and I can select multiple options. After pressing save, the field "page_types" is saved in the user/config/plugins/PLUGINNAME.yaml as page_types: '' (e.g. with no data).

jgonyea commented 2 years ago

Browser: Firefox (Win x64)

PHP 7.4.26 Grav 1.7.30 Form 5.1.6 Admin 1.10.30

jgonyea commented 2 years ago

Seems that the validate.type: array is not working properly. If that option is broken onto multiple lines like:

vaidate:
  type: array

then the saving works properly. The Learn site should be updated to reflect this.

Thanks to Djamil on Discord for finding the issue.

w00fz commented 2 years ago

@mahagr is this a valid issue or is it a deprecated usage of dot-chained properties? If that's the case can you update the docs, as it appears to be misleading with the information.

If not a bug, @jgonyea kindly provided a PR for this: https://github.com/getgrav/grav-learn/pull/973

mahagr commented 2 years ago

It's just a documentation issue.