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

Fixed selecitze field not properly updating its value when the options attribute is provided and more than one option is selected. #1236

Merged
merged 1 commit into from
Nov 28, 2017

Conversation

parcand
Copy link
Contributor

@parcand parcand commented Oct 2, 2017

See #1229

…ns` attribute is provided and more than one option is selected.
@rhukster
Copy link
Member

rhukster commented Oct 2, 2017

I'm not really able to get this to work, even with your last field definition:

  someselect:
      type: selectize
      label: Preface
      selectize:
        items:
          - ABC
          - DEF
        options:
          - text: ABC
            value: ABC
          - text: DEF
            value: DEF
          - text: GHI
            value: GHI
      validate:
        type: commalist

Is this what you have? What's the purpose of the selectize: items: ? No matter what i put i don't get any values saved.

@parcand
Copy link
Contributor Author

parcand commented Oct 3, 2017

Oh, I'm sorry, I can see where the confusion comes from.

I am no longer providing the selectize: items: as part of the field definition. This pull request introduces a small change which now automatically populate theselectize: items: from the actual field value.

Just to give you a bit of background information, it appears that using the selectize: options: attribute leads to a small glitch which prevents the widget from properly loading the comma-separated values from the HTML input element itself. For some reason it only loads a single item, even if you previously saved more that one.

So in order to fix that problem you need to pass pre-selected values directly to the widget using theselectize: items:. It would be quite impractical to do it at the blueprint level, that's why I came up with this solution which merge values directly in the twig template of the selectize widget.

    someselectize:
      type: selectize
      label: A selectize field
      selectize:
        options:
          - text: ABC
            value: ABC
          - text: DEF
            value: DEF
          - text: GHI
            value: GHI
      validate:
        type: commalist

@parcand
Copy link
Contributor Author

parcand commented Oct 3, 2017

I've done some tests with an up-to-date Grav installation and it seems to work as expected, for both config blueprints and pages blueprints (with the header field name prefix).

@rhukster rhukster merged commit d3064a0 into getgrav:develop Nov 28, 2017
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

Successfully merging this pull request may close these issues.

2 participants