At the moment I'm struggling with sending data through my register.phtml.

The situation right now is, I've created a module that allows me to override the core register.phtml with my own custom register.phtml which contains several fields. Using Pbmage_AttributeManager I've created several customer attributes.

What I am trying to do is, connect the fields that I have made in my custom register.phtml to the attributes that I have created in the database.

I've been looking at the core register.phtml, but I have yet to figure out what their way is of sending data to the database.

Thank you for taking your time reading this.

  • have you tried this link – Shashank Kumrawat Oct 12 '18 at 13:33
  • I've used a code similar to that one before, but because it dumps all the attributes under the "additional information" it didn't really work out. Since I'm supposed to follow a certain list, that's why I made a fresh register.phtml so I could edit the title it was under. – Hazukashi Oct 12 '18 at 13:39

As I understand, you want to show your custom customer attributes inside of the customer registration form. To achieve this, you don't need to directly modify the register.phtml template - Magento 2 has much better and flexible solution for this.

All you have to do is to assign the required customer attributes to the customer forms you want via UpgradeData script.

You need to do put this part in your UpgradeData.php:

use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;


$attribute = $customerSetup->getEavConfig()->getAttribute(
$attribute->setData('used_in_forms', ['adminhtml_customer', 'customer_account_create']);

I've found this in an example there: https://gist.github.com/zzpaul/bebd89f4665a8ac81db5e3c4ac953ab7

  • Thank you for your response. Just to make sure, if I were to use the code you provided, would I be able to edit the heading it's under? ex. "Company Information" which has several fields to fill in the attributes under it. – Hazukashi Oct 15 '18 at 6:59
  • Sure, you may modify the code in any way – Nikita Abrashnev Oct 15 '18 at 8:15
  • Where would I do that? And would I be able to add multiple headings? – Hazukashi Oct 15 '18 at 8:17
  • Managed to make it work, thank you for the code and example. – Hazukashi Oct 15 '18 at 13:52
  • Np, sorry, couldn't answer before on your questions above – Nikita Abrashnev Oct 15 '18 at 16:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.