Xavierleo Posted December 10, 2019 Share Posted December 10, 2019 hello , i build a module wich adds phone field to customer registration , in front the input is displayed well and the new customer is added. In the BO when editing that customer , it shows me an error : Quote Notice: Undefined variable: customerForm in the file src\PrestaShopBundle\Controller\Admin\Sell\Customer\CustomerController.php (line 203) here is module hooks code : public function hookActionCustomerFormBuilderModifier($params) { $formBuilder = $params['form_builder']; $formBuilder->add('phone', [ 'label' => $this->l('Phone Number'), 'type' => 'text', 'hideTabs' => false, 'required' => false, 'options' => [ 'constraints' => [ new CleanHtml([ 'message' => $this->l('This field is invalid', 'Admin.Notifications.Error'), ]), ], ], ]); $customerForm = new Customer((int)$params['id']); $params['data']['phone'] = $customerForm->phone; $formBuilder->setData($params['data']); } public function hookActionAfterCreateCustomerFormHandler(array $params) { $this->updateData($params['form_data'], $params); } public function hookActionAfterUpdateCustomerFormHandler(array $params) { $this->updateData($params['form_data'], $params); } protected function updateData(array $data, $params) { $customerFormData = new Customer((int)$params['id']); $customerFormData->phone = $data['phone']; $customerFormData->save(); } 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