Magento 2 - Adding custom fields to customer registration form?

Multi tool use
Magento 2 - Adding custom fields to customer registration form?
I am needing to add a few custom fields to the customer registration form within Magento 2.
The fields I need to add are:
Company Registration Number, Business Type (Which will be a select list) and Sage Account Number
I've looked at a few resources and attempted to setup a customer attribute but I haven't had much luck.
This is my code so far in InstallData.php
:
InstallData.php
public function __construct(CustomerSetupFactory $customerSetupFactory) {
$this->customerSetupFactory = $customerSetupFactory;
}
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
MagentoCustomerModelCustomer::ENTITY,
'company_reg_number',
[
'type' => 'varchar',
'label' => 'Comapny Registration Number',
'input' => 'text',
'required' => true,
'visible' => true,
'user_defined' => true,
'position' => 999,
'system' => 0,
]
);
$companyRegNo = $this->eavConfig->getAttribute(Customer::ENTITY, 'company_reg_number');
// more used_in_forms ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address']
$companyRegNo->setData(
'used_in_forms',
['adminhtml_customer']
);
$companyRegNo->save();
}
I expect to see a new field called Company Registration Number in the backend customer section here:
Customer Account Information backend page
Not sure if I'm missing something?
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.