I've developed a plugin that allows me to create a custom user profile. It works and I'm able to add/remove fields as necessary.
The issue I'm facing is: How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?
Because the users database has name in it I know that I can't just drop the filed. So, I was thinking it might be best to concat the first and last name into the 'name' field for entry into the database. However, when trying to implement this I ran into issues.
To remove the 'name' field from the registration form I added the following to the onContentPrepareForm() function in my profile plugin:
$form->removeField('name');
This successfully removes the field. However, I now need to set name = first name + last name elsewhere. I've read on these forums that I could change the data in the onUserBeforeSave() function. Unfortunately that is not called before I get a validation error message saying that registration failed and that I need to enter a name. I then tried to turn required off in the registration.xml file. That didn't work (or I changed the wrong file).
I then thought that perhaps I could put it in the onContentPrepareData() function. The issue I ran into here is that 'name' was removed from the form and it's not in the $data array.
What should I do? What is the proper way to fix this?
Thanks in advance for your assistance.