CakeRC搜索插件 - 未定义索引PrgComponent.php,第389行

时间:2015-05-27 12:35:37

标签: php cakephp search

我试图安装CakeRc搜索插件,以便在搜索时有漂亮的网址,但我不断收到以下错误:

Notice (8): Undefined index: Properties [APP\Plugin\Search\Controller\Component\PrgComponent.php, line 389]

Warning (4096): Argument 1 passed to PrgComponent::serializeParams() must be an array, null given, called in ...\app\Plugin\Search\Controller\Component\PrgComponent.php on line 390 and defined [APP\Plugin\Search\Controller\Component\PrgComponent.php, line 268]

Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [APP\Plugin\Search\Controller\Component\PrgComponent.php, line 404]

Warning (4096): Argument 1 passed to PrgComponent::exclude() must be an array, null given, called in ...\app\Plugin\Search\Controller\Component\PrgComponent.php on line 405 and defined [APP\Plugin\Search\Controller\Component\PrgComponent.php, line 325]

Warning (2): Invalid argument supplied for foreach() [APP\Plugin\Search\Controller\Component\PrgComponent.php, line 327]

这是我的模特:

class Properties extends AppModel {

public $actsAs = array('Search.Searchable');

public $filterArgs = array(
    'location' => array(
        'type' => 'value',
    ),
    'area' => array(
        'type' => 'value',
    )
);

}

这是我的控制者:

class PropertiesController extends AppController {

public $helpers = array('Property', 'Image');
public $uses = array('Properties','Area');
public $components = array('Search.Prg');

public $presetVars = array(
    array('field' => 'location', 'type' => 'value'),
    array('field' => 'area', 'type' => 'value'),
);

public function search() {

    //PRG

    $this->Prg->commonProcess();

    ....
 }
}

这是我的观点:

        <?php
        echo $this->Form->create('Properties', array(
            'url' => array_merge(array('action' => 'search'), $this->params['pass']),
            'class' => 'advance-search-form clearfix'
        ));
        ?>
        <div class="option-bar">
            <label>
                Location
            </label>
            <span class="selectwrap">
                <?php
                foreach ($locations as $location)
                    $locations_[$location['Area']['location']] = $location['Area']['location'];

                echo $this->Form->input(
                    'location', array(
                    'options' => $locations_,
                    'empty' => 'Any',
                    'class' => 'search-select',
                    'type' => 'select',
                    'id' => 'select-location',
                    'name'=> 'location',
                    'label' => false,
                        )
                );
                ?>
            </span>
        </div>

        <div class="clearfix"></div>

        <div class="option-bar">
            <label>
                Area
            </label>
            <span class="selectwrap">
            <?php
            echo $this->Form->input(
                'area', array(
                'empty' => 'Any',
                'class' => 'search-select',
                'type' => 'select',
                'id' => 'select-area',
                'name' => 'area',
                'label' => false
                    )
            );
            ?>
            </span>
        </div>
        <input type="submit" value="Search" class=" real-btn btn">
   <?php echo $this->Form->end(); ?>

我试图从第389行更改prgComponent.php文件:

  $searchParams = $this->controller->request->data[$modelName];

  $searchParams = $this->controller->request->data;

这会清除错误,但网址仍然不显示为prg格式...... :( 我明白了:

 properties/search?url=properties%2Fsearch&location=&area=

任何帮助将不胜感激,谢谢。

1 个答案:

答案 0 :(得分:0)

通过将prgComponent.php第389行更改为

来管理解决问题
$searchParams = $this->controller->request->data;

并将控制器$ components var更改为:

public $components = array(
    'Search.Prg' => array(
        'commonProcess' => array('paramType' => 'named'),
        'presetForm' => array('paramType' => 'named')
    )
);

现在将网址设为

properties/search/location:Central Algarve/area: