0

I have added one customer address custom attribute. it is showing in customer address form i want to show that as coulum in customer address grid in admin with value.

i have added this code:

 <column name="addressval"  sortOrder="95">
        <settings>
            <filter>select</filter>
            <dataType>select</dataType>
            <label translate="true">addressval</label>
        </settings>
    </column>

Column is added but the value is not showing in this. how to get the value which was set in form?

1 Answer 1

2

options node is missed , which is essential to show the values

<options class="Vendor\Module\Model\Customer\Address\Attribute\Source\CustomAttribute"/>

Add a source Model class which returns the values of your customer address attribute and use the source model class in options node like this

<column name="addressval" component="Magento_Ui/js/grid/columns/select" sortOrder="95">
        <settings>
            <filter>select</filter>
            <options class="Vendor\Module\Model\Customer\Address\Attribute\Source\CustomAttribute"/>
            <dataType>select</dataType>
            <label translate="true">addressval</label>
        </settings>
    </column>
4
  • I tried this.... but still not getting value on that field
    – sam
    Commented Feb 19, 2021 at 6:00
  • then most likely its because of your source model class...check whether it returns the option values for your select column.
    – Haijerome
    Commented Feb 19, 2021 at 8:30
  • just one question, what should I write in that custom attribute file. can you give me some code examples?
    – sam
    Commented Feb 19, 2021 at 11:46
  • i am getting this error: [2021-02-22 09:47:38] report.CRITICAL: Warning: array_values() expects parameter 1 to be array, object given in /var/www/html/xxx-anchor/vendor/magento/module-ui/Component/Form/Element/AbstractOptionsField.php on line 60 {"exception":"[object] (Exception(code: 0): Warning: array_values() expects parameter 1 to be array, object given in /var/www/html/xxx-anchor/vendor/magento/module-ui/Component/Form/Element/AbstractOptionsField.php on line 60 at /var/www/html/xxx-anchor/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    – sam
    Commented Feb 22, 2021 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.