So, i already have created my custom attributes in the InstallData.php file, i now need to show some of them on the Customer table in the admin area of the website. The attributes i need to display are of the varchar type in the database, below is the code i used to create one of the custom attributes.
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'codice_fiscale', [ 'type' => 'varchar', 'label' => 'codice fiscale', 'input' => 'text', 'source' => '', 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, 'backend' => '' ]); $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'codice_fiscale') ->addData(['used_in_forms' => [ 'adminhtml_customer', 'adminhtml_checkout', 'customer_account_create', 'customer_account_edit' ]]); $attribute->save();
I've tried some options i found on the web but nothing worked
Solved! Go to Solution.
try this link: https://magento.stackexchange.com/questions/126820/magento-2-how-to-add-a-custom-column-in-customer-...
this link helped me,
thanks
Sorry with customer table do you mean customer grid?
Good, so you should put all these flags on "1" is_used_on_grid, is_visible_in_grid, is_filterable_in_grid, is_searchable_in_grid check customer_eav_attribute table, then you will see your attribute on "Columns" button to add dynamically on the grid.
i've checked that table in the database but i don't have a record for my custom attributes there, should i add it manually using the correct attribute_id of the attributes i want to add?
@daniel_bertagnolli if you don't see your attribute there something wrong with your create script, did you face some error when run setup:upgrade command?
the script ran fine and the attributes have been created, i can find them in the eav_attribute table but not in the table you mentioned
Still not working, anyone got an idea please?
Create YourNamespace/YourModule/view/base/ui_component/customer_form.xml
<?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <fieldset name="customer"> <field name="codice_fiscale" formElement="input"> <settings> <visible>true</visible> </settings> </field> </fieldset> </form>
Hope this will help you.if yes then,Click Kudos & Accept as Solution
Hi @RanjeetBhojwani ,
sorry for not answering sooner, i've tried your solution but it's still not showing the new column.
Ofcourse i ran setup:upgrade, cache:clean and cache:flush before testing it