8000 [Bug]: Inconsistent behavior with Multiselect using OptionsProvider providing numeric values · Issue #11623 · pimcore/pimcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug]: Inconsistent behavior with Multiselect using OptionsProvider providing numeric values #11623
Closed
@podarcis

Description

@podarcis

Expected behavior

When the options provider returns an integer (e.g. Pimcore ID of an object) for value, for instance: ['key' => 'foobar', 'value' => 1]:

  • Persisted values of multiselect should be the selected options when opening the object.
  • Consistent behavior regardless of render type "List" or "Tags".

Actual behavior

  • Multiselect (render type "List") has no selected options reflecting the persisted values.
  • Render type "List" and "Tags" should behave the same - here only render type "List" is affected.

Steps to reproduce

  1. Create a DataObject class.
  2. Add a field of type Multiselect with render type "List" (default).
  3. Make it a "Dynamic Multiselect" by specifying an options provider (see below). Return valid options according to the docs of "Dynamic Select Typed" in format ['key' => 'foobar', 'value' => 1] - use an integer for value.
  4. Open the data object, select multiple options and save.
  5. Reload the object and discover that no option is selected (value is persisted correctly, though).

Possible solutions:

  1. Specify the option provider option format to always return a string for value and fix the documentation.
  2. Server-side: Transform/cast the options' values provided by the options provider.
  3. Client-side pimcore.object.tags.multiselect: Cast the value in prepareStoreDataAndFilterLabels() to string.

Code snippet options provider

<?php

namespace App;

use Pimcore\Model\DataObject;

class MultiOptionsProvider implements DataObject\ClassDefinition\DynamicOptionsProvider\MultiSelectOptionsProviderInterface
{

    /**
     * @inheritDoc
     */
    public function getOptions($context, $fieldDefinition)
    {
        return [
            ['key' => 'foo1', 'value' => 1],
            ['key' => 'foo2', 'value' => 2],
            ['key' => 'foo3', 'value' => 3],
        ];
    }

    /**
     * @inheritDoc
     */
    public function hasStaticOptions($context, $fieldDefinition)
    {
        return true;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0