cancel
Showing results for 
Search instead for 
Did you mean: 

in magento 2.4.5 data not saved of custom attribute added by db_schema.xml

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

in magento 2.4.5 data not saved of custom attribute added by db_schema.xml

Could someone assist me in resolving this issue? I've created a custom attribute for customers, but when I attempt to save data from the admin panel for any customer, it doesn't get saved. Here is the details

--db_schema.xml
        <?xml version="1.0"?>
    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
        <table name="customer_entity">
            <column xsi:type="varchar" name="dataprivacy_attribute" nullable="true" length="255" comment="Data Privacy Status"/>
        </table>
    </schema>
view/adminhtml/ui_component/customer_form.xml

 

<?xml version="1.0"?>
    <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
        <fieldset name="account_information" sortOrder="50">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Custom Fields</item>
                </item>
            </argument>
            <field name="dataprivacy_attribute">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="sortOrder" xsi:type="number">10</item>
                        <item name="dataType" xsi:type="string">text</item>
                        <item name="dataScope" xsi:type="string">dataprivacy_attribute</item>
                        <item name="formElement" xsi:type="string">input</item>
                        <item name="label" xsi:type="string" translate="true">Custom Attribute</item>
                    </item>
                </argument>
            </field>
        </fieldset>
    </form>

 

 

1 REPLY 1

Re: in magento 2.4.5 data not saved of custom attribute added by db_schema.xml

@rina_test 

Hey,

You have to create an observer to save the data you want. You can create 'customer_save_after' observer or related plugin.

Thank You!

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.