Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggleable: true within type: list is checking everything on save regardless #688

Closed
jjui opened this issue Jul 8, 2016 · 6 comments
Closed
Assignees

Comments

@jjui
Copy link

jjui commented Jul 8, 2016

After spoken with @flaviocopes we narrowed it down to this.

If toggleable: true is present for fields within type: list, they all will be checked on save regardless if there are any data provided to the field/s or not. Heard that you, @w00fz where the expert on this ;)

What can be a solution?

Lazy example:

dependencies:
  - { name: grav, version: '~1.1' }

form:
  validation: loose
  fields:

    tabs:
      type: tabs
      active: 1

      fields:
        -
          type: tab
          title: General

          fields: 

            general:
              type: section
              title: General
              underline: true

              fields:

                enabled:
                  type: toggle
                  label: PLUGIN_ADMIN.PLUGIN_STATUS
                  highlight: 1
                  default: 0
                  options:
                    1: PLUGIN_ADMIN.ENABLED
                    0: PLUGIN_ADMIN.DISABLED
                  validate:
                    type: bool

                built_in_css:
                  type: toggle
                  label: Use built in CSS
                  highlight: 1
                  default: 1
                  options:
                    1: PLUGIN_ADMIN.ENABLED
                    0: PLUGIN_ADMIN.DISABLED
                  validate:
                    type: bool

        -
          type: tab
          title: Notifications

          fields:

            notifications_info:
              type: section
              title: Notifications
              underline: true

              fields:

                notifications:
                  type: list
                  style: vertical

                  fields:

                    info_message:
                      type: display
                      style: vertical
                      markdown: true
                      content: '### Basic'
# ID
                    .id:
                      type: hidden
                      default: "random()"
                      evaluate: true
                      validate:
                        type: string
# Enabled
                    .enabled:
                      type: toggle
                      label: Activate
                      highlight: 1
                      default: 1
                      options:
                        1: PLUGIN_ADMIN.ENABLED
                        0: PLUGIN_ADMIN.DISABLED
                      validate:
                        type: bool
# Message
                    .message:
                      type: editor
                      label: Message:
                      default: 'stripped'

                    info_settings:
                      type: display
                      style: vertical
                      markdown: true
                      content: '### Settings'

                    info_visit_limit:
                      type: display
                      style: vertical
                      markdown: true
                      content: '**Visit limits**'
# Display on number
                    .display_on_number:
                      type: text
                      size: x-small
                      label: Display on visit number:
                      toggleable: true
                      append: visit
                      validate:
                        type: int
                        min: 1
# Hide on number
                    .hide_on_number:
                      type: text
                      size: x-small
                      label: Hide on visit number:
                      toggleable: true
                      append: visit
                      validate:
                        type: int
                        min: 1

                    info_time_limit:
                      type: display
                      style: vertical
                      markdown: true
                      content: '**Time limits**'
# Start time limit
                    .start_time_limit:
                      type: text
                      size: x-small
                      label: Display after:
                      toggleable: true
                      append: seconds
                      validate:
                        type: int
                        min: 1
# End time limit
                    .end_time_limit:
                      type: text
                      size: x-small
                      label: Hide after:
                      toggleable: true
                      append: seconds
                      validate:
                        type: int
                        min: 1

                    info_datetime:
                      type: display
                      style: vertical
                      markdown: true
                      content: '**Date & Hour**'
# Start date
                    .start_date:
                      type: datetime
                      size: small
                      label: Display on date:
                      toggleable: true
# End date
                    .end_date:
                      type: datetime
                      size: small
                      label: Hide on date:
                      toggleable: true
@flaviocopes
Copy link
Contributor

Replicated, if inside a list, a toggleable field initially is unchecked.

At the first save, it's saving as expected (not being persisted to the yaml), but it's being shown as checked in the page, so at the next save it's persisted to the yaml.

@w00fz w00fz self-assigned this Jul 9, 2016
@w00fz w00fz closed this as completed in 387030c Jul 9, 2016
@w00fz
Copy link
Member

w00fz commented Jul 9, 2016

Should be fixed 😄
Can you guys give it a try now?

@jjui
Copy link
Author

jjui commented Jul 9, 2016

Tested, success! 😄 Thank you very much @w00fz

@jjui
Copy link
Author

jjui commented Jul 9, 2016

@w00fz, cannot reopen issue, but type: datetime still gets auto checked on save! File new issue?
Tho very nice to find these bugs ^^

Best!

@w00fz
Copy link
Member

w00fz commented Jul 9, 2016

Try adding default: '' for those entries. I think it's because it automatically tries to populate with the current date otherwise.

@jjui
Copy link
Author

jjui commented Jul 9, 2016

My bad! Setting default to none works like a charm ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants