php - CakePHP: Use value from dropdown to populate a view -


this 1 of things feel should easier i'm making it. have dropdown list populated values table. want user select list item , have list item id returning set of rows on subsequent view. here dropdown code view:

    echo $this->form->input('mission_id', array('label' => 'mission id'));     echo $this->html->link(__('view'), array('action' => 'index')); 

and here simple browse controller, returns in table:

public function browse() {     $this->set('requirements', $this->paginator->paginate('requirement')); } 

i cannot figure out how make controller receive value user selects can filter next view. when "view" clicked, should return 500 rows contain selected id. don't know put after 'action' => 'index' carry on browse controller.

you need wrap input in form submits index action , replace link submit button:-

echo $this->form->create(null, ['action' => 'index']); echo $this->form->input('mission_id', array('label' => 'mission id')); echo $this->form->submit(__('view')); echo $this->form->end(); 

then in index action check mission_id using $this->request->data , whatever need there:-

public function index() {     if (!empty($this->request->data['modelname']['mission_id'])) {         // submitted mission_id value     } } 

if must use link submit form you'll want @ using javascript cause link submit parent form. better use button this.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -