网址参数有问题


Trouble with URL parameters

我正在制作一个搜索表单,我想在 url 中发布搜索依据的值。 但是,我在让网址包含参数时遇到问题。 如果我在视图中键入值,他们将发布(如果我键入"12345"而不是$this->search_zip)。 目前,除 url 外,搜索按预期工作。我目前正在从表单中获取搜索词,是否需要更改控制器设置才能从 url 获取它们? 如果是这种情况,我将如何过滤?

最终,我希望我的网址阅读:

结果/12345/其他参数

我目前正在得到

结果

无论我在表单中键入什么变量。

模块配置

return array(
    'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'segment',
                'options' => array(
                    'route'    => '/',
                    'constraints' => array(
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ),
                    'defaults' => array(
                        'controller' => 'Application'Controller'Index',
                        'action'     => 'index',
                    ),
                ),
                'may_terminate' => true, //START OF CHILD ROUTES
                'child_routes' => array(
                'results' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route' => 'results[/:search_zip][/:search_industry]',
                        'defaults' => array(
                            'controller' => 'Application'Controller'Index',
                            'action'     => 'results',

结果视图

$form->setAttribute('action', $this->url(
 'home/results',
 array(
     'action' => 'results',
     'search_zip'=> $this->search_zip,
     'search_industry' => 'industry_name'
    echo $this->formRow($form->get('industry_name'));//this is the form field
    echo $this->formSubmit($form->get('submit'));

控制器

 //beginning of the results action
    $request = $this->getRequest();   
             $form = new SearchForm($dbAdapter);  
             if ($request->isPost()) {
                 $search = new MainSearch();          
                 $form->setInputFilter($search->getInputFilter());                
                 $form->setData($request->getPost());  
                 if ($form->isValid()) { 

在我的结果操作结束时,我返回表单和结果(根据专辑示例)

     return array(
        'form' => $form,
        'pros' => $fetchPros,
              );

谢谢米

//This will give you an array containing your desired parameters
$params = $this->params()->fromRoute();
//Then you can simply use them like this
$search_zip = $params['search_zip'];
$search_industry  = $params['search_industry'];