tijojoel Posted July 25, 2017 Share Posted July 25, 2017 Hi, I wanted to add a dropdown list with the profile on creation of profile. I had used override, the dropdown is coming correctly and saved in database also but when editing or viewing it is not making the "dropdown selected ". Also so many warning are coming with undefined name, undefined type. I will share my code :- AdminProfilesController.php --------------------------------------------------------------- class AdminProfilesController extends AdminProfilesControllerCore { public function __construct() { $this->bootstrap = true; $this->context = Context::getContext(); $this->table = 'profile'; $this->className = 'Profile'; $this->multishop_context = Shop::CONTEXT_ALL; $this->lang = true; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->addRowActionSkipList('delete', array(1)); $this->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash' ) ); $this->fields_list = array( 'id_profile' => array( 'title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'name' => array('title' => $this->l('Name')) ); $this->identifier = 'id_profile'; /* Fetch All Profiles*/ $admin_levels = Profile::adminLevels(); foreach ($admin_levels as $row) { $values_access[] = array( 'id' => $row['id_admin'], 'name' => $this->l($row['admin_level_name']), 'label' => $this->l($row['admin_level_name']), 'val' => $row['id_admin'] ); } $this->fields_form_override = array( 'legend' => array( 'title' => $this->l('Profile'), 'icon' => 'icon-group' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'lang' => true, ), ), 'input' => array( 'type' => 'select', 'label' => $this->l('Access Levels'), 'name' => 'id_admin_level', 'lang' => true, 'col' => '4', 'options' => array( 'query' => $values_access, 'id' => 'id', 'name' => 'name', 'val' => 'val' ), ), 'submit' => array( 'title' => $this->l('Save'), ) ); $list_profile = array(); foreach (Profile::getProfiles($this->context->language->id) as $profil) { $list_profile[] = array('value' => $profil['id_profile'], 'name' => $profil['name']); } parent::__construct(); } } In Classes folder Profile.php -------------------------------------------------- class Profile extends ProfileCore { /** @var string Name */ public $name; public $id_admin_level; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'profile', 'primary' => 'id_profile', 'multilang' => true, 'fields' => array( /* Lang fields */ 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), 'id_admin_level' => array('type' => self::TYPE_INT, 'lang' => true) ), ); /** Fetching Admin Access Levels */ public static function adminLevels() { $access_level = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'admin_levels'); return $access_level; } } Can anyone help me to sort out this. I am using prestashop 1.6 Error screenshot is attached. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now