I added new custom attribute to customer form. i can save this attribute from magento admin panel. I included this attribute field in Customer Registration Form. How to map and save this attribute form frontend registration form to customer entity table. .I think we can't use magic setters to save in magento2. How to achieve this using interfaces or any other methods

$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        'label'            => 'Example Attribute',
        'required'         => 0,
        'system'           => 0,
        'position'         => 100

$customerSetup->getEavConfig()->getAttribute('customer', 'example_attribute')
    ->setData('used_in_forms', ['adminhtml_customer'])

I included this attribute field in Registration form

<fieldset class="fieldset">
    <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Additional Information') ?></span></legend><br>

    <div class="field">
        <label for="example_attribute" class="label"><span><?php /* @escapeNotVerified */ echo __('Example Attribute') ?></span></label>
        <div class="control">
            <input type="text" name="website_url" id="example_attribute" title="<?php /* @escapeNotVerified */ echo __('Example Attribute') ?>" >

  • 1
    by changing the used in form fields i able to save the customer form frontend $customerSetup->getEavConfig()->getAttribute('customer', 'example_attribute') ->setData('used_in_forms', ['customer_account_create', 'customer_account_edit', 'checkout_register', 'adminhtml_customer']) ->save(); – Phani Kumar Jan 7 '16 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.