heimrichhannot / contao-entity-filter-bundle
This module offers an input type for selecting one or more entities by comfortably 'clicking together' sql-like conditions.
Installs: 7 743
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 0
Type:contao-bundle
pkg:composer/heimrichhannot/contao-entity-filter-bundle
Requires
- php: ^8.1
- contao/core-bundle: ^4.13 || ^5.0
- doctrine/dbal: ^3.9 || ^4.0
- heimrichhannot/contao-field-value-copier-bundle: ^1.0
- heimrichhannot/contao-list-widget-bundle: ^1.1
- heimrichhannot/contao-multi-column-editor-bundle: ^2.0
- heimrichhannot/contao-utils-bundle: ^2.226 || ^3.0
- symfony/dependency-injection: ^5.4 || ^6.0 || ^7.0
- symfony/event-dispatcher-contracts: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- contao/contao-rector: dev-main
- contao/manager-plugin: ^2.13
- phpstan/phpstan: ^2.1
- phpstan/phpstan-symfony: ^2.0
- rector/rector: ^2.0
- symplify/easy-coding-standard: ^12.5
README
This module offers an input type for selecting one or more entities by comfortably "clicking together" sql-like conditions.
Features
- "click together" conditions for filtering (aka selecting) arbitrary contao entities
- load existing filter conditions from other records
- display a result list of your filtering right in the contao record's edit view
Technical instructions
This module offers 3 comfortable different functions for adding the widgets mentioned before right to your dca.
Note: Of course, you can also copy these 3 functions and customize them if they don't suit your needs
Add the entity filter widget to your dca:
Hint: If you like to set the table to be filtered dynamically, you can do that in an onload_callback.
But you still have to call the following function in your dca and not the callback because else exclude wouldn't be set correctly.
\Contao\System::getContainer()->get('huh.entity_filter.manager')->addFilterToDca(
    // the name of the field
    'memberConditions',
    // your dca
    'tl_md_recipient_list',
    // the table to be filtered
    'tl_member'
);
Add a field for copying entity filters from other records:
\Contao\System::getContainer()->get('huh.entity_filter.manager')->addFilterCopierToDca(
    // the name of the field
    'filterCopier',
    // your dca
    'tl_recipient_list',
    // the dca where the field values are situated you want to copy (usually the same as your dca)
    'tl_recipient_list',
    // the entity_filter field
    'memberConditions',
    // a custom options_callback -> if left out, ['huh.field_value_copier.util.field_value_copier_util', 'getOptions'] is used
    ['huh.field_value_copier.util.field_value_copier_util', 'getOptions'],
    // config parameters for field value copier widget
    [
        'labelPattern' => '%title% (ID %id%)'
    ]
);
Add a live-reloaded table for showing the results of your conditions:
\Contao\System::getContainer()->get('huh.entity_filter.manager')->addListToDca(
    // the name of the field
    'memberList',
    // your dca
    'tl_recipient_list',
    // the entity_filter field
    'memberConditions',
    // the table being filtered
    'tl_member',
    // the header fields of the table
    array(
        'title',
        'firstname',
        'lastname',
        'email',
    )
);
Events
| Name | Arguments | 
|---|---|
| ModifyEntityFilterQueryEvent | string $table,string $field,$activeRecord,string $query,string $where,array $values,array $listDca | 
