Trying to add a group_id radio button set in Magento Pro v1.11
Following along with
http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html and
http://developersindia.info/magento/magento-override-frontend-controller.html,
which is working to a point, but the group_id is not getting written to the db.
my module, thus far:
Directory Structure
app/code/local
- WACI
-- Customer
--- controllers
---- AccountController.php
--- etc
---- config.xml
config.xml
<config>
<modules>
<WACI_Customer>
<version>0.1.0</version>
</WACI_Customer>
</modules>
<global>
<fieldsets>
<customer_account>
<group_id><create>1</create></group_id>
</customer_account>
</fieldsets>
</global>
<frontend>
<routers>
<customer>
<args>
<modules>
<WACI_Customer before="Mage_Customer_AccountController">
WACI_Customer
</WACI_Customer>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
AccountController.php
<?php
/**
*Customer account controller
*
* @package WACI_Customer
*/
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
class WACI_Customer_AccountController extends Mage_Customer_AccountController
{
/**
* Create customer account action
*/
public function createPostAction()
{
// contents of createPostAction(), with some extra logic
/**
* Initialize customer group id
*/
/* catch groupid at account creation */
if($this->getRequest()->getPost('group_id')){
$customer->setGroupId($this->getRequest()->getPost('group_id'));
} else {
$customer->getGroupId();
}
// rest of method
}
}
theme../persistent/customer/form/register.phtml
<div class="input-box">
<label for="group_id"><?php echo $this->__('Select your customer group') ?></label><br />
<?php
$groups = Mage::helper('customer')->getGroups()->toOptionArray();
foreach ($groups as $group){
echo '<input type="radio" name="group_id" value="'.$group['value'].'" class="validate-radio" >'.$group['label'].'</input><br/>';
}
?>
</div>
So, the radio buttons with the groups show up fine at registration, but the data isn't being written to the db, as group still shows as general in the admin/manage customers
- I don't really want to modify core files, as the article describes,
- I'm not certain that I'm properly overwriting the mage
accountController
class (maybe theres a better way to do this?)
What am I mucking up?