I want to add mobile no field in registration form. here is the code
InstallData.php
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* See LICENSE.md bundled with this module for license details.
*/
namespace Semaio\AdvancedLogin\Setup;
use Magento\Customer\Model\Customer;
use Magento\Customer\Setup\CustomerSetup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* Class InstallData
*
* @package Semaio\AdvancedLogin\Setup
*/
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var \Magento\Customer\Setup\CustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
*/
public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
// Add new customer attribute
$customerSetup->addAttribute(
Customer::ENTITY,
'customer_number',
[
'label' => 'Customer Number',
'input' => 'text',
'required' => false,
'sort_order' => 10,
'visible' => true,
'system' => false,
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
'is_filterable_in_grid' => true,
'is_searchable_in_grid' => true
]
);
// add attribute to form
/** @var $attribute */
$attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'customer_number');
$attribute->setData('used_in_forms', ['adminhtml_customer','checkout_register','customer_account_create','customer_account_edit','adminhtml_checkout']);
$attribute->save();
$setup->endSetup();
}
}
view/frontend/templates/form/register.phtml
<div class="field required">
<label for="customer_number" class="label"><span><?= __('CustomerNumber') ?></span></label>
<div class="control">
<input type="text" name="customer_number" id="customer_number" value="<?= $block->escapeHtml($block->getFormData()->getCustomerNumber()) ?>" title="<?= __('CustomerNumber') ?>" class="input-text" data-validate="{required:true, 'validate-phoneStrict':true}">
</div>
</div>
can anyone help me where is the problem?
customer_number
attribute ineav_attribute
table?