Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ not the latest version from GitHub.

First, obtain the plugin. If you're using Git, run this while in your app folder:

git submodule add git://github.com/lecterror/cakephp-filter-plugin.git Plugin/Filter
git submodule add git://github.com/lecterror/cakephp-filter-plugin.git app/Plugin/Filter
git submodule init
git submodule update

Expand All @@ -28,9 +28,38 @@ plugin manually to your `app/Plugin/Filter/` folder.
To use the plugin, you need to tell it which model to filter and which fields to use. For
a quick tutorial, visit <http://lecterror.com/articles/view/cakephp-generic-filter-plugin>

* Ensure the plugin is loaded in `app/Config/bootstrap.php` by calling `CakePlugin::load('Filter');`

If you need more than this plugin provides by default, there are ways to customize it, see
this article: <http://lecterror.com/articles/view/cakephp-filter-plugin-advanced-usage>

## Synopsis

### Adapt your controller, in this example, we add ModelName.field to the filter list.

```php
class ExampleController extends AppController
{
var $components = array('Filter.Filter');

var $filters = array(
'index' => array(
'ModelName' => array(
'ModelName.field',
),
)
);
}
```

### Adapt the view :

In the app/View/Modelname/index.ctp
Before the table, insert :
```php
<?php echo $this->Filter->filterForm('ModelName', array('legend' => 'Search')); ?>
```

## Contributing ##

If you'd like to contribute, clone the source on GitHub, make your changes and send me a pull request.
Expand Down