Tuesday, July 8, 2014

cant access dropdown list values

Hi,

I am using paginate with a search box. It works fine until I use a drop down box to select values rather than use a textbox.
I cant get the selected value from a dropdown box to appear in the querystring.
So I just select a value in a textbox and then click search , i then get the values from a query string and do a paginate find.
However a dropdown list instead of a textbox isnt working.

controller

 public function myindex5() {
      
         $this->set( 'filterSuburb',$this->Student->find('list', array('fields' => array('Student.address_suburb') )));
 
       $havefilter=false;       
              
        if (!empty($this->request->query['address_suburb'])) {
           
           $suburb=$this->request->query['address_suburb'];
           $havefilter=true; 
            
        }
        else $suburb='%';

          if ($havefilter) {
             
             
           $this->paginate = array(
                 'conditions'=>array('Student.address_suburb LIKE' => $suburb,'Student.last_name LIKE' => $lastname ),
                'limit' => 3,
                'order' => array('Student.id' => 'ASC','Student.first_name' => 'ASC'),
                'contain' => array('TutoringType','Referral')   
                );
          
                    
           $this->set('student',  $this->paginate());
          }
          $this->set('havefilter',  $havefilter);
       
    }
   

view
    <?php
               // app/View/Locations/index.ctp
               
               
                echo $this->Form->create('Student', array('type' => 'get','url' => array('controller' => 'students', 'action' => 'myindex5' )));
               // echo $this->Form->input('address_suburb', array('label' => 'suburb'));
                 echo $this->Form->input('address_suburb', array('type' => 'select','options' => $filterSuburb));
               echo $this->Form->input('last_name', array('label' => 'last name'));
           
                echo $this->Form->end('Search');
                ?>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: