php - Trouble with URL parameters -
i working on search form post searched values in url. having trouble getting url include parameters however. post if key in values in view( if instead of $this->search_zip key '12345'). search works desired except url. getting search terms form, need change controller setup them url instead? if case how filter?
ultimately url read:
results/12345/otherparam
i getting
results
no matter variables key form.
module config
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',
results view
$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 form field echo $this->formsubmit($form->get('submit'));
controller
//beginning of 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()) {
at end of resultsaction return form , results (per album example)
return array( 'form' => $form, 'pros' => $fetchpros, );
thank you, m
//this give array containing desired parameters $params = $this->params()->fromroute(); //then can use them $search_zip = $params['search_zip']; $search_industry = $params['search_industry'];
Comments
Post a Comment