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

crudEAV cannot handle "Use Default Value" #29

Open
ioweb-gr opened this issue Jan 31, 2022 · 1 comment
Open

crudEAV cannot handle "Use Default Value" #29

ioweb-gr opened this issue Jan 31, 2022 · 1 comment

Comments

@ioweb-gr
Copy link

I've created an EAV entity with this template, and added a custom attribute with store view scope.

e.g.

        $attributes = [];
        $attributes['name'] = [
            'type' => 'varchar',
            'label' => 'Name',
            'input' => 'text',
            'required' => true, //true/false
            'sort_order' => 10,
            'global' => ScopedAttributeInterface::SCOPE_STORE,
            'group' => 'General',
        ];

        foreach($attributes as $attributeCode => $attributeData){
            $this->eavSetup->addAttribute(CookieSetup::ENTITY_TYPE_CODE, $attributeCode, $attributeData);
        }

My problem here is when trying to save the object in the backend for a different store view other than default, I'm unable to reset the value to use default.

image

I've tried modifying the ui form component to add the "Use Default Value" checkbox to test, but it's totally ignored

e.g.

        <field name="name" formElement="input" sortOrder="20" >
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="service" xsi:type="array">
                        <item name="template" xsi:type="string">ui/form/element/helper/service</item>
                    </item>
                </item>
            </argument>
            <settings>
                <visible>true</visible>
                <dataType>text</dataType>
                <label translate="true">Name</label>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
            </settings>
        </field>

image

And after saving the value still remains. It's never deleted for the current store view.

I'm assuming something is missing from the resourceModel to handle the "Use Default Value"?

@ioweb-gr
Copy link
Author

ioweb-gr commented Feb 3, 2022

I've noticed that even without "Use Default Value" if I resave the entity with an empty value on the store view level, the upper scope level value is deleted.

So in a tree like this

All Store Views (Value Default) 
|--Website (Value Website)
|----Store View 1 (Value Store View 1)
|----Store View 2 (Value Store View 2)

If I navigate to Store View 2 and save twice with an empty value

On the first save the "Value Store View 2" is deleted.
On the second save the "Value Website" is deleted even though I didn't change scope.

Any ideas what this bug is?

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

1 participant