GroupType is a child of ChoiceType. It is used to display a selection for customer groups and comes pre-populated with the list of customer groups configured in PrestaShop.
PrestaShopBundle\Form\Admin\Sell\CustomerPrestaShopBundle\Form\Admin\Sell\Customer\GroupType| Option | Type | Default value | Description |
|---|---|---|---|
| choices | array | From provider | Automatically populated from GroupByIdChoiceProvider::getChoices(). |
| choice_translation_domain | boolean | false | Disables translation for choice labels (names come from database). |
None.
<?php
// path/to/your/CustomType.php
use PrestaShopBundle\Form\Admin\Sell\Customer\GroupType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CustomType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('default_group_id', GroupType::class, [
'label' => 'Default customer group',
'required' => false,
'autocomplete' => true,
'placeholder' => null,
]);
}
}
For better UX with many customer groups, enable the autocomplete feature:
<?php
$builder->add('default_group_id', GroupType::class, [
'label' => 'Default customer group',
'autocomplete' => true,
'placeholder' => null,
]);
When you need to allow selecting multiple groups (e.g., for group access), consider using MaterialChoiceTableType with the same choice provider:
<?php
use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTableType;
// Inject GroupByIdChoiceProvider in your form type constructor
$builder->add('group_ids', MaterialChoiceTableType::class, [
'label' => 'Group access',
'empty_data' => [],
'choices' => $this->groupByIdChoiceProvider->getChoices(),
'display_total_items' => true,
]);
GroupByIdChoiceProviderid_group in the ps_group tableps_group_lang and displayed in the current language