# `mix cinder.gen.filter`
[🔗](https://github.com/sevenseacat/cinder/blob/v0.12.1/lib/mix/tasks/cinder.gen.filter.ex#L2)

Generate and configure a custom Cinder filter based on built-in filters.

This task creates a new custom filter module that delegates to a built-in filter
as a starting point, allowing you to customize specific behaviors while keeping
the rest of the implementation. It automatically registers the filter in your
application configuration.

## Example

```bash
mix cinder.gen.filter MyApp.Filters.CustomText custom_text --template=text

```

## Arguments

* `module` - The module name for the filter (e.g., MyApp.Filters.CustomText)
* `type` - The filter type identifier (e.g., custom_text)

## Options

* `--template` or `-t` - Base filter to copy from: text, select, multi_select, boolean, radio_group, date_range, number_range
* `--no-tests` - Skip generating test file
* `--no-config` - Skip automatic configuration registration
* `--no-setup` - Skip ensuring Cinder.setup() is called in application

## Available Templates

* `text` - Based on Cinder.Filters.Text (text input with operators)
* `select` - Based on Cinder.Filters.Select (dropdown selection)
* `multi_select` - Based on Cinder.Filters.MultiSelect (multiple selection)
* `boolean` - Based on Cinder.Filters.Boolean (true/false/any selection)
* `radio_group` - Based on Cinder.Filters.RadioGroup (mutually exclusive radio options)
* `date_range` - Based on Cinder.Filters.DateRange (from/to date picker)
* `number_range` - Based on Cinder.Filters.NumberRange (from/to number input)

## What it does

1. Creates a custom filter module that delegates to the chosen built-in filter
2. Automatically updates the filter type to your custom type
3. Generates comprehensive test file (unless --no-tests)
4. Automatically adds the filter to your :cinder configuration
5. Provides clear examples of how to customize the behavior

## Customization

The generated filter starts by delegating all behavior to the base filter but with
your custom type. You can then override any callback function to customize:

* `render/4` - Customize the HTML rendering
* `process/2` - Customize input processing and validation
* `validate/1` - Customize filter validation logic
* `build_query/3` - Customize query building
* `default_options/0` - Customize default options
* `empty?/1` - Customize empty value detection

The generated filter will be immediately ready to use in your tables.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
