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

EntitySearchInputType

This form type is used for an OneToMany (or ManyToMany) association, it allows to search a list of entities (based on a remote URL) and associate it. It is based on the CollectionType form type which provides prototype features to display a custom template for each associated item.

Type options

Option Type Default value Description

Code example

$builder->add('related_products', EntitySearchInputType::class, [
    'label' => $this->trans('Related products', 'Admin.Catalog.Feature'),
    'label_tag_name' => 'h3',
    'entry_type' => RelatedProductType::class,
    'entry_options' => [
        'block_prefix' => 'related_product',
    ],
    'remote_url' => $this->router->generate('admin_products_v2_search_associations', [
        'languageCode' => $this->employeeIsoCode,
        'query' => '__QUERY__',
    ]),
    'min_length' => 3,
    'filtered_identities' => $productId > 0 ? [$productId] : [],
    'placeholder' => $this->trans('Search product', 'Admin.Catalog.Help'),
])

Preview example

EntitySearchInputType rendered in form example