sococa Posted September 10, 2024 Share Posted September 10, 2024 (edited) Bonjour à tous, Je fais un module pour que les champs du formulaire d'adresse se retrouvent dans le formulaire d'inscription : Comme vous le voyez c'est bien parti. Mon seul problème concerne le pays. Le choix me renvoie systématiquement 'Array'. Pourtant, je récupère bien l'id_country (vu avec l'inspecteur d'éléments). $additionalFields[] = (new FormField) ->setName('id_country') ->setType('select') ->setLabel($this->l('Pays')) ->setRequired(true) ->setAvailableValues( array_map(function($country) { return [ 'id' => $country['id_country'], // Identifiant du pays 'label' => $country['name'] // Nom du pays ]; }, Country::getCountries($this->context->language->id, true)) ); Voici ce que me renvoie le var_dump de Country::getCountries($this->context->language->id, true); : array (size=2) 3 => array (size=15) 'id_country' => int 3 'id_lang' => int 1 'name' => string 'Belgique' (length=8) 'id_zone' => int 1 'id_currency' => int 0 'iso_code' => string 'BE' (length=2) 'call_prefix' => int 32 'active' => int 1 'contains_states' => int 0 'need_identification_number' => int 0 'need_zip_code' => int 1 'zip_code_format' => string 'NNNN' (length=4) 'display_tax_label' => int 1 'country' => string 'Belgique' (length=8) 'zone' => string 'Europe' (length=6) 8 => array (size=15) 'id_country' => int 8 'id_lang' => int 1 'name' => string 'France' (length=6) 'id_zone' => int 1 'id_currency' => int 0 'iso_code' => string 'FR' (length=2) 'call_prefix' => int 33 'active' => int 1 'contains_states' => int 0 'need_identification_number' => int 0 'need_zip_code' => int 1 'zip_code_format' => string 'NNNNN' (length=5) 'display_tax_label' => int 1 'country' => string 'France' (length=6) 'zone' => string 'Europe' (length=6) Quelqu'un a une idée ? Je dois mal appeler la data du tableau mais je n'arrive pas à bien l'appeler . Je vous partage aussi le module complet en zip. Merci ! ps_customregistrationfields.zip Edited September 12, 2024 by sococa (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted September 10, 2024 Share Posted September 10, 2024 (edited) Bonjour. $selectedDefaultCountry = $this->context->country->id; $additionalFields['country'] = (new FormField) ->setName('country') ->setType('select') /* ->setType('countrySelect') */ ->setLabel($this->l('Pays')) ->setRequired(true) ->setValue($selectedDefaultCountry); foreach ($countries as $country) { $additionalFields['country']->addAvailableValue( $country['id_country'], $country['name'] ); } ps_customregistrationfields.zip Edited September 10, 2024 by ps8modules.com (see edit history) Link to comment Share on other sites More sharing options...
sococa Posted September 12, 2024 Author Share Posted September 12, 2024 merci @ps8modules.com c'est nickel ! 1 Link to comment Share on other sites More sharing options...
Asu34 Posted September 12, 2024 Share Posted September 12, 2024 Bonjour, ce n'est pas paramétrable en version 8.x ? Car ça l'était sur les précédentes versions : Link to comment Share on other sites More sharing options...
sococa Posted September 12, 2024 Author Share Posted September 12, 2024 salut @Asu34, En tout cas je ne l'ai pas vu et je ne le trouve pas ... Si c'est possible, j'aurai alors perdu un temps fou ^^' mais ce serait cool quand même. 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