Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Extending the registration form
 
djoos
Jr. Member
 
Total Posts:  28
Joined:  2009-04-09
 

Hi guys,

I’m quite new to Magento and had a look around for some modifications we’d like to do to our Magento installation…

Ok, first some more information on what we’re trying to achieve:
we’d like to add a couple of more fields to the registration form, validate them (custom validation - preferrably a call to a function that will return true/false) and store them in the Magento database.

Firstly: I’ve had a look at this Wiki post: http://www.magentocommerce.com/wiki/custom_account/registration_fields, which helped me a lot. It made it possible for me to add a test field to the form and -when overriding the core code- save them in the database. Now, it’s not a good idea to hack it into the core code, so I’d actually love to find a way to override the core code with some local code… I tried to merge the modifications with this Wiki post to customize code: http://www.magentocommerce.com/wiki/groups/174/changing_and_customizing_magento_code#custom_modules, but that’s when it went wrong grin

FYI:
* the test field I added is called “myfield” in the code below (attached) and the company is “mycompany”.
* I ran the following code as well:
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$AttrCode = 'myfield';
$settings = array (
'position' => 1,
'is_required'=> 0
);
$setup->addAttribute('1', $AttrCode, $settings);
?>

* the cache is disabled

Then I created a mycompany_All.xml in \app\etc\modules...:
\app\etc\modules => mycompany_All.xml (see attachment for content of file)

Then, I created the following files and folders:
\app\code\local\mycompany\Customer\etc => config.xml (see attachment for content of file)
\app\code\local\mycompany\Customer\Model\Entity => Setup.php (see attachment for content of file)

Clearly it’s got something to do with the way I need to override things properly, since doing the modifications in the core classes (\app\code\core\Mage\Customer\etc.config.xml and \app\code\core\Mage\Customer\Model\Entity\Setup.php) did the trick…

After solving this issue I need to find a way to have custom validation on the fields, but let’s not clutter it too much for now! grin
Thanks in advance for your help!

File Attachments
config.xml  (File Size: 2KB - Downloads: 85)
mycompany_All.xml  (File Size: 1KB - Downloads: 50)
Setup.php  (File Size: 11KB - Downloads: 48)
 
Magento Community Magento Community
Magento Community
Magento Community
 
djoos
Jr. Member
 
Total Posts:  28
Joined:  2009-04-09
 

I’ve had another look at it after doing some other work and going over everything again, making use of http://www.magentocommerce.com/wiki/groups/174/changing_and_customizing_magento_code#custom_modules, it worked out fine!

Now I need to have a look into custom validation… If anyone has got any suggestions, please let me know! grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
IrwinMFletcher
Member
 
Total Posts:  32
Joined:  2009-05-30
 

Did you find any way to do validation (custom or otherwise) on the registration form?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top