PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 6, 2024
Let's talk code, commerce and open source.

Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

TypeaheadCustomerCollectionType

This form class is responsible for selecting a customer.

Type options

Option Type Default value Description

Code example

$builder->add(
    'sp_id_customer',
    TypeaheadCustomerCollectionType::class,
    [
        // "%QUERY" is appended to url in order to avoid "%" sign being encoded into "%25",
        // it used as a placeholder to replace with actual query in JS
        'remote_url' => $this->router->generate('admin_customers_search', ['sf2' => 1]) . '&customer_search=%QUERY',
        'mapping_value' => 'id_customer',
        'mapping_name' => 'fullname_and_email',
        'placeholder' => $this->translator->trans('All customers', [], 'Admin.Global'),
        'template_collection' => '<div class="media-body"><div class="label">%s</div><i class="material-icons delete">clear</i></div>',
        'limit' => 1,
        'required' => false,
        'label' => $this->translator->trans('Add customer', [], 'Admin.Catalog.Feature'),
    ]
)

Preview example

TypeaheadCustomerCollectionType rendered in form using textarea