Jump to content

Edit History

beubz2

beubz2


tried some new things

Hello!

I want to create a radio field that would allow the user to choose in which group their account will be created (eg: individuals, professionals). And if the "Professionals" button is checked, the SIRET and Company fields will appear. I modified CustomerFormatter.php to get the radio field I want, but I don't know how to persist the information to database as well.

        $groups = Group::getGroups($this->language->id);
            $groupField = (new FormField())
                ->setName('id_default_group')
                ->setType('radio-buttons')
                ->setLabel(
                    $this->translator->trans(
                        'Statut',
                        [],
                        'Shop.Forms.Labels'
                    )
                );

            foreach ($groups as $group) {
                $groupField->addAvailableValue($group->id_group,$group->name);
            //    var_dump($group);
            }

I tried this, but Prestashop gives me an error: ContextErrorException
Notice: Trying to get property 'id_group' of non-object
However with a vardump, I do have an "id_group" output (I was inspired by "Gender")

Thanks in advance!

professionnal radio.png

beubz2

beubz2

Hello!

I want to create a radio field that would allow the user to choose in which group their account will be created (eg: individuals, professionals). And if the "Professionals" button is checked, the SIRET and Company fields will appear. I modified CustomerFormatter.php to get the radio field I want, but I don't know how to persist the information to database as well.


        $format['statut'] = (new FormField())
            ->setName('radio_field')
            ->setRequired(true)
            ->setType('radio-buttons')
            ->setAvailableValues(array('key' => 'Particulier', 'key2' => 'Professionnel'))
            ->setLabel(
                $this->translator->trans(
                    'Statut',
                    [],
                    'Shop.Forms.Labels'
                )
            );

Thanks in advance !

professionnal radio.png

×
×
  • Create New...