EAV attribute and FrontEnd

by user2410626   Last Updated December 07, 2017 11:09 AM

I am confused about EAV attribute in Magento 2.

Let's say I have a customer EAV (dropdown) with a custom model.

In the Frontend, do I have to put the form in templates with layout ? I mean, whats the purpose of : visible_on_front and used_in_forms, customer_account_edit if I have to put it by myself on phtml template files ?

 $customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'name', [
        'type' => 'int',
        'label' => 'magasin_adherent',
        'input' => 'select',
        'source' => 'vendor\module\Model\Customer\Attribute\Source\MagasinAdherent',
        'required' => true,
        'visible' => true,
        'position' => 333,
        'system' => false,
        'backend' => ''
                 'searchable' => true,
                'filterable' => true,
                'comparable' => true,
                'visible_on_front' => true,           
    ]);


    $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'magasin_adherent')
        ->addData(['used_in_forms' => [
            'adminhtml_customer',
            'adminhtml_checkout',
            'customer_account_create',
            'customer_account_edit'
        ]]);
    $attribute->save();


Related Questions


Adblock extension blocks Magento product images

Updated July 07, 2017 17:09 PM

Magento best practices: try / catch in templates

Updated March 16, 2017 13:09 PM