Code Monkey home page Code Monkey logo

cakephp-filter-plugin's People

Contributors

baberuth22 avatar bancer avatar codelingobot avatar curtisgibby avatar gemal avatar lecterror avatar mlingureanu avatar netors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp-filter-plugin's Issues

Strict (2048): Only variables should be assigned by reference [APP/Plugin/Filter/Controller/Component/FilterComponent.php, line 201]

After upgrading to PHP 5.4.17 (Mac OSX 10.9) received the following error

Strict (2048): Only variables should be assigned by reference [APP/Plugin/Filter/Controller/Component/FilterComponent.php, line 201]

$workingModel =& ClassRegistry::init($fieldModel);

changed to

$workingModel = ClassRegistry::init($fieldModel);

removed the error.

As of PHP 5, the new operator returns a reference automatically, so assigning the result of new by reference results in an E_DEPRECATED message in PHP 5.3 and later, and an E_STRICT message in earlier versions.

Required => false seems to be broken

Hey. Thansk for the great plugin. It seems I am ot the only one who has this issue. (some others mentioned it on your blog). I'm using Cake 2.4.9

I have a field that doesn't have the issue (not required), and one that always is required. even when I add required => false.

I've tried using other settings on the field, but it remains required.

UPDATE: it seems the settings used in the model cannot be overriden.
I had:

class Post extends AppModel {
public $validate = array(
'title' => array(
'rule' => 'notEmpty'
),
'body' => array(
'rule' => 'notEmpty'
)
);

Guess that 'solves' that.

FilteredBehavior and CakePHP 2.3.x

CakePHP v2.3, PHP v5.4

The FilteredBehavior returns an empty $query['conditions']-array.
A little research learned me this:

function beforeFind(Model $Model, $query)
{
...
$settings = $this->settings[$Model->alias];
$values = $this->_filterValues[$Model->alias];

    foreach ($settings as $field => $options)
    {
        $this->addFieldToFilter($Model, $query, $settings, $values, $field, $options); 
    }

    ...
    return $query;
}

Inhere, the methodcall
$this->addFieldToFilter($Model, $query, $settings, $values, $field, $options); returns an empty $query['conditions']-array.

Some new investigations:

protected function buildFilterConditions(array $query, $field, $options, $value)
{
...

}

The method creates the $query['conditions'] well, but after the transfer to beforeFind, it is empty. The only place where the $query['conditions']-array is properly set is after switch{ ... }.

any suggestions?

Problems w/ CakePHP 2.1.3

I'm trying to give your plugin a spin on CakePHP 2.13 but I'm hitting an error. Has it been tested on 2.1.x?

I've followed your article (http://lecterror.com/articles/view/cakephp-generic-filter-plugin) to get it setup:
git clone into Plugin/Filter
added: CakePlugin::load('Filter'); to Config/bootstrap.php
added: $components = array('Filter.Filter'); to AppController.php
added: var $filters = array
(
'index' => array(
'Item' => array(
'Item.code',
'Item.name',
'Mfg' => array(
'Mfg.code',
'Mfg.name'
),
)
)
);
to ItemsController.php
added: echo $filter->filterForm('Item', array('legend' => 'Search')); to the top of Items/index.ctp

I'm hitting the following error message:
Items

Notice (8): Undefined variable: filter [APP/View/Items/index.ctp, line 4]
Code Context

    ob_start();

    include $___viewFn;

$___viewFn = '/var/www/html/poms01/app/View/Items/index.ctp'
$___dataForView = array(
'viewFilterParams' => array(
),
'items' => array(
),
'acl' => object(AclComponent) {},
'user' => array(
),
'logged_in' => true
)
$viewFilterParams = array(
(int) 0 => array(
),
(int) 1 => array(
),
(int) 2 => array(
)
)
$items = array(
(int) 0 => array(
)
)
$acl = object(AclComponent) {}
$user = array(
'id' => '1',
'username' => 'admin',
'name' => 'Admin',
'email' => '[email protected]',
'group_id' => '1',
'created' => '06/19/2012 17:04:54',
'modified' => '06/19/2012 17:04:54'
)
$logged_in = true

include - APP/View/Items/index.ctp, line 4
View::_evaluate() - CORE/Cake/View/View.php, line 910
View::_render() - CORE/Cake/View/View.php, line 874
View::render() - CORE/Cake/View/View.php, line 465
Controller::render() - CORE/Cake/Controller/Controller.php, line 959
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 110
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 85
[main] - APP/webroot/index.php, line 92

Fatal error: Call to a member function filterForm() on a non-object in /var/www/html/poms01/app/View/Items/index.ctp on line 4 Call Stack: 0.0007 341276 1. {main}() /var/www/html/poms01/app/webroot/index.php:0 0.0443 1779296 2. Dispatcher->dispatch() /var/www/html/poms01/app/webroot/index.php:92 0.0645 2607592 3. Dispatcher->_invoke() /var/www/html/poms01/lib/Cake/Routing/Dispatcher.php:85 0.5128 7639632 4. Controller->render() /var/www/html/poms01/lib/Cake/Routing/Dispatcher.php:110 0.5221 7919400 5. View->render() /var/www/html/poms01/lib/Cake/Controller/Controller.php:959 0.5463 9392360 6. View->_render() /var/www/html/poms01/lib/Cake/View/View.php:465 0.5470 9392388 7. View->_evaluate() /var/www/html/poms01/lib/Cake/View/View.php:874 0.5477 9489236 8. include('/var/www/html/poms01/app/View/Items/index.ctp') /var/www/html/poms01/lib/Cake/View/View.php:910

Any suggestions?

Cheers,
Scott

Testcases are not working

Hello,

while trying to fix the belongsTo bug I realized that the testcases are not working. Here my environment:

cake 2.0.4
phpunit 3.6.4

Some errors are due to some changes in the framework, especially the function expectError() and trigger_error are apparently
not supported in this way anymore.

You can use $this->setExpectedException('PHPUnit_Framework_Error'); instead, but I'm not so sure whether this would fit all test-cases.

Missing Helper Error

Hi,
I use cakePHP 2.4.4 and I get this error message.

Missing Helper
Error: FilterHelper could not be found.

Error: Create the class FilterHelper below in file: app\View\Helper\FilterHelper.php

<?php
class FilterHelper extends AppHelper {

}
Notice: If you want to customize this error message, create app\View\Errors\missing_helper.ctp

Deprecation Notice: does not comply with psr-4 autoloading standard

Deprecation Notice: Class Filter\Test\TestCase\Controller\Component\FilterTestCase located in plugins/Filter/tests\TestCase\Controller\Component\FilterComponentTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Filter\Test\TestCase\DocumentCategoriesTable located in plugins/Filter/tests\TestCase\MockObjects.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201

Component doesn't check model behaviors' methods or mapped methods

In FilterComponent::beforeRender, when there's a selector specified, you check to see if a model has the specified method...

if (!method_exists($workingModel, $settings['selector']))
{
// trigger the error

... and if it doesn't, you trigger an error.

This doesn't take into account if the model has access to the selector method through a behavior, either explicitly declared in the behavior or through a magic "mapMethod." Adding a check against the model's BehaviorCollection->hasMethod resolves this problem.

if (
    ! method_exists($workingModel, $settings['selector']) &&
    ! $workingModel->Behaviors->hasMethod($settings['selector'])
)
{
// now you can trigger that error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.