romwn Posted April 6, 2016 Share Posted April 6, 2016 Bonjour à tous ! Je développe un module de gestion dans le backoffice, dans lequel l'admin peut ajouter un certain type d'employé. J'aimerais cependant ajouter un nouveau champ qui est son arrondissement, que je stockerais dans la BDD en VARCHAR(10). Comment puis-je mettre à jour le renderForm afin de prendre en compte ce nouveau critère ? Merci d'avance ! Ci-joint ma fonction renderForm public function renderForm() { $id_employee = 7; /** @var Employee $obj */ if (!($obj = $this->loadObject(true))) { return; } $available_profiles = Profile::getProfiles($this->context->language->id); if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_) { $this->errors[] = Tools::displayError('You cannot edit the SuperAdmin profile.'); return parent::renderForm(); } $this->fields_form = array( 'legend' => array( 'title' => $this->l('Employees'), 'icon' => 'icon-user' ), 'input' => array( array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('Prénom'), 'name' => 'firstname', 'required' => true ), array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('Nom'), 'name' => 'lastname', 'required' => true ), array( 'type' => 'hidden', 'class' => 'fixed-width-xl', 'label' => $this->l('id profile'), 'name' => 'id_profile', 'required' => true ), array( 'type' => 'text', 'class'=> 'fixed-width-xxl', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'required' => true, 'autocomplete' => false ), array( 'type' => 'text', 'class'=> 'fixed-width-xxl', 'label' => $this->l('Telephone'), 'name' => 'phone_number', 'required' => true ), array( 'type' => 'text', 'class'=> 'fixed-width-xxl', 'label' => $this->l('Arrondissement'), 'name' => 'arrondissement', 'required' => true ), ), ); if ($this->restrict_edition) { $this->fields_form['input'][] = array( 'type' => 'change-password', 'label' => $this->l('Password'), 'name' => 'passwd' ); if (Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController'))) { $this->fields_form['input'][] = array( 'type' => 'prestashop_addons', 'label' => 'PrestaShop Addons', 'name' => 'prestashop_addons', ); } } else { $this->fields_form['input'][] = array( 'type' => 'password', 'label' => $this->l('Password'), 'hint' => sprintf($this->l('Password should be at least %s characters long.'), Validate::ADMIN_PASSWORD_LENGTH), 'name' => 'passwd' ); } $this->fields_form['input'] = array_merge($this->fields_form['input'], array( array( 'type' => 'select', 'label' => $this->l('Language'), 'name' => 'id_lang', //'required' => true, 'options' => array( 'query' => Language::getLanguages(false), 'id' => 'id_lang', 'name' => 'name' ) ) )); $this->fields_value['active'] = true; //$this->fields_value['id_profile'] = $id_employee; $this->fields_value = array('id_profile' => $id_employee); // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) { foreach ($available_profiles as $i => $profile) { if ($available_profiles[$i]['id_profile'] == _PS_ADMIN_PROFILE_) { unset($available_profiles[$i]); break; } } } if (Shop::isFeatureActive()) { $this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int)_PS_ADMIN_PROFILE_); $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'hint' => $this->l('Select the shops the employee is allowed to access.'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save'), ); if (empty($obj->id)) { $this->fields_value['id_lang'] = $this->context->language->id; } return parent::renderForm(); } Link to comment Share on other sites More sharing options...
Mediacom87 Posted April 6, 2016 Share Posted April 6, 2016 Bonjour, vous devez surtout passer par un override et non une modification du coeur de PrestaShop. 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