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

[Data objects] No inheritance in option provider #4956

Closed
BlackbitNeueMedien opened this issue Sep 9, 2019 · 0 comments · Fixed by #4972

Comments

@BlackbitNeueMedien
Copy link
Contributor

commented Sep 9, 2019

By default the object provided to

cannot access inherited value of its parent(s) as AbstractObject::doGetInheritedValues() returns false.

To reproduce this:

  1. Create data option provider:
<?php
namespace AppBundle\Model\OptionProvider;

use Pimcore\Model\DataObject\ClassDefinition;
use Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface;
use Pimcore\Model\DataObject\Concrete;

class ExampleOptionProvider implements SelectOptionsProviderInterface
{
    public function getOptions($context, $sourceFieldDefinition)
    {
        $options = [];

        $object = $context['object'];
        if(!$object instanceof Concrete) {
            return [];
        }

        return  ['key' => $object->getName(), 'value' => $object->getName()];
    }

    public function hasStaticOptions($context, $fieldDefinition)
    {
        return false;
    }

    public function getDefaultValue($context, $fieldDefinition)
    {
        return null;
    }
}
  1. Create data object class with:
  • input field "name"
  • select field. This select field gets the above data option provider
  1. Create object "parent" and enter "ABC" into field "name"
  2. Create object "child" below "parent" -> there is only an empty option as inheritance is disabled when getOptions() gets called.

Of course this can be fixed by explicitly calling AbstractObject::setGetInheritedValues(true) and later reset it to the original value - but imho there is no reason why inheritance is disabled here in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.