rikki_maha24 Posted December 5, 2012 Share Posted December 5, 2012 Hi Everyone, I new to Prestashop. I have three different roles(Distributor/Consumer/Retailer). On registration page user can select role which he wants to choose. When he clicks on create your account along with other fileds Role field should be displayed with drop down list. What I have done is: 1) Added New Table Role in DB with fields Id and Name. 1) Added below code in AuthController.php public function initContent() { --------- --------- // Added $this->context->smarty->assign('roles', Role::getRoles()); 2) Created Class Role : class RoleCore extends ObjectModel { public $id_role; public $name; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'role', 'primary' => 'id_role', 'fields' => array( 'id_role' => array('type' => self::TYPE_INT, 'required' => true), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 12), ), ); public function __construct($id_role = null, $id_lang = null, $id_shop = null) { parent::__construct($id_role, $id_lang, $id_shop); } public static function getRoles($id_role = null) { $roles = new Collection('Role', $id_role); return $roles; } } 3) Added code in authentication.tpl <form action="{$link->getPageLink('authentication', true)}" method="post" id="account-creation_form" class="std"> { ---------------------- --------------------- <p class="radio required"> <span>{l s='Role'}</span> {foreach from=$roles key=k item=role} <input type="radio" name="id_role" id="id_role{$role->id}" value="{$role->id}" {if isset($smarty.post.id_role) && $smarty.post.id_role == $role->id}checked="checked"{/if} /> <label for="id_role{$role->id}" class="top">{$role->name}</label> {/foreach} </p> But I'm getting an error: Technical error. Please help me to fix. I have just started wokring on prestashop so need your valueable inputs on the same. Thanks, Ricky Link to comment Share on other sites More sharing options...
Recommended Posts