# FilterRemoval

> Rewrites a panel filter group in the query parameters and renders the banner dropping single filters: replaces the group with the active filters or removes selected attributes while resetting pagination, without changing unrelated navigation parameters.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Web](/docs/extensions/yii3-debug/reference/web/index.md) › FilterRemoval

| final class | `Yii3\Debug\Web\FilterRemoval` |
| --- | --- |
| Source | [`src/Web/FilterRemoval.php`](https://github.com/yii3/debug/blob/main/src/Web/FilterRemoval.php#L18) |

Rewrites a panel filter group in the query parameters and renders the banner dropping single filters: replaces the
group with the active filters or removes selected attributes while resetting pagination, without changing unrelated
navigation parameters.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`banner()`](#method-banner) static | Renders the active-filter banner whose links remove single filters from the panel query. | `FilterRemoval` |
| [`queryParams()`](#method-queryParams) static | Returns the query parameters with the named filter removed. | `FilterRemoval` |
| [`withGroup()`](#method-withGroup) static | Replaces the filter group with the active filters, or removes it when no filter is active. | `FilterRemoval` |

## Method details

### banner() <span id="method-banner"></span>

```php
public static function banner(array<string, string> $activeFilters, PHPForge\Debug\Panel\PanelRenderContext $context, array<array-key, mixed> $queryParams, string $prefix): string
```

Renders the active-filter banner whose links remove single filters from the panel query.

The clear-all link drops the union of the submitted group keys and the active ones, so values the panel search
rejected are cleared together with the filters they left out.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$activeFilters` | `array<string, string>` | Attribute-to-value map of the currently applied filters. |
| `$context` | `PHPForge\Debug\Panel\PanelRenderContext` | Context resolving the panel URL and exposing the submitted query. |
| `$queryParams` | `array<array-key, mixed>` | Query parameters already normalized by the panel. |
| `$prefix` | `string` | Filter group the removed attributes belong to. |

**Returns**

`string`: Rendered banner, or `''` when no filter is active.

### queryParams() <span id="method-queryParams"></span>

```php
public static function queryParams(array<array-key, mixed> $queryParams, string $prefix, list<string> $without): array<array-key, mixed>
```

Returns the query parameters with the named filter removed.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$queryParams` | `array<array-key, mixed>` | Query parameters already normalized by the panel. |
| `$prefix` | `string` | Filter group to update. |
| `$without` | `list<string>` | Attributes to remove from that group. |

**Returns**

`array<array-key, mixed>`: Query parameters without those attributes.

### withGroup() <span id="method-withGroup"></span>

```php
public static function withGroup(array<array-key, mixed> $queryParams, string $prefix, array<string, string> $filters, list<string> $drop = []): array<array-key, mixed>
```

Replaces the filter group with the active filters, or removes it when no filter is active.

The group keeps its current position in the query, so link query strings preserve their parameter order.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$queryParams` | `array<array-key, mixed>` | Query parameters already normalized by the panel. |
| `$prefix` | `string` | Filter group to replace. |
| `$filters` | `array<string, string>` | Active filters; an empty set removes the group. |
| `$drop` | `list<string>` | Unrelated parameters to remove, such as `view`. |

**Returns**

`array<array-key, mixed>`: Query parameters carrying the replaced group.