massimopasquali Posted November 11, 2020 Share Posted November 11, 2020 Hello, I have to modify customer form in backoffice, I need to add a dropdown filed, carrier list and in particolar I have to show the name of carrier, but saveing the "id_carrier". in my module I have add a hook, the new dropdown filed is "vettore1", nut it doesn't work. Can you suggest me liek to do that? tnx in advance public function hookActionCustomerFormBuilderModifier(array $params) { $queryBus = $this->get('prestashop.core.query_bus'); $formBuilder = $params['form_builder']; $formBuilder->add('panthera_id', null, [ 'label' => $this->getTranslator()->trans('panthera_id', [], 'Modules.Backoffice.Admin'), 'help' => 'Codice cliente Panthera.', 'required' => false, 'empty_data' => '', ]); $formBuilder->add('optin', SwitchType::class, [ 'label' => $this->getTranslator()->trans('Privacy', [], 'Modules.Backoffice.Admin'), 'required' => false, ]); $formBuilder->add('vettore1', null, [ 'label' => $this->getTranslator()->trans('vettore1', [], 'Modules.Backoffice.Admin'), 'required' => false, 'options' => $idevents = array( array( 'idevents' => 1, 'name' => 'methode 1' ), array( 'idevents' => 2, 'name' => 'methode 2' ), array( 'idevents' => 3, 'name' => 'methode 3' ), ), //'id' => 'idevents', //'name' => 'vettore1' ]); $formBuilder->add('vettore2', null, [ 'label' => $this->getTranslator()->trans('vettore2', [], 'Modules.Backoffice.Admin'), 'required' => false, 'empty_data' => '', ]); $formBuilder->add('porto_assegnato', SwitchType::class, [ 'label' => $this->getTranslator()->trans('porto_assegnato', [], 'Modules.Backoffice.Admin'), 'required' => false, ]); $formBuilder->add('abilita_consegna_mezzo_fni', SwitchType::class, [ 'label' => $this->getTranslator()->trans('abilita_consegna_mezzo_fni', [], 'Modules.Backoffice.Admin'), 'required' => false, ]); //$queryBus = $this->get('prestashop.core.query_bus'); $pantheraIdSettings = $queryBus->handle(new GetPantheraIdSettingsForForm($params['id'])); $isOptInSettings = $queryBus->handle(new GetOptInSettingsForForm($params['id'])); //$vettore1Settings = $queryBus->handle(new GetVettore1SettingsForForm($params['id'])); $vettore2Settings = $queryBus->handle(new GetVettore2SettingsForForm($params['id'])); $params['data']['panthera_id'] = $pantheraIdSettings->panthera_id(); $params['data']['optin'] = $isOptInSettings->isOptIn(); //$params['data']['vettore1'] = $vettore1Settings->description(); $params['data']['vettore2'] = $vettore2Settings->description(); $params['data']['porto_assegnato'] = "111"; $params['data']['abilita_consegna_mezzo_fni'] = "111"; $formBuilder->setData($params['data']); } Link to comment Share on other sites More sharing options...
massimopasquali Posted November 13, 2020 Author Share Posted November 13, 2020 SOLVED Link to comment Share on other sites More sharing options...
Ali Gadimi Posted February 12, 2021 Share Posted February 12, 2021 I have the same problem. There doesn't seems be a SelectType or something. Can you explain how did you do it? Link to comment Share on other sites More sharing options...
Ali Gadimi Posted February 12, 2021 Share Posted February 12, 2021 oh i found it. And yeah this is how i did it: $formBuilder->add('NAME_OF_FIELD', ChoiceType::class, [ 'label' => 'YOUR_LABEL', 'required' => false, 'choices' => [ 'OPTION_NAME' => 'VALUE', 'OPTION_NAME' => 'VALUE', 'OPTION_NAME' => 'VALUE' ], ]); 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