Advertisement
Guest User

Untitled

a guest
Jul 15th, 2013
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1.  
  2. ....
  3.         $formfields = array('1','2','3','4');
  4.  
  5.         foreach ($formfields as $value) {
  6.             if($data['ExistingMemberName' . $value] != ''){
  7.                 // If they selected an existing member look them up and select the first in the list
  8.                 // This assumes that only 1 person by that name is in the system...
  9.                 $member = Member::get()
  10.                     ->filter(array(
  11.                         'FirstName' => preg_replace("/\([^)]+\)/","",$data['ExistingMemberName' . $value])))
  12.                     ->first();
  13.                    
  14.                 // Adds the exisiting member to the team
  15.                 $team->Members()->add($member);
  16. .....
  17.  
  18.     public function results() {              
  19.                 if($query = $this->getSearchQuery()) {
  20.                         //Search for our query - Pretty basic example here
  21.                         $Results = Member::get()->filter(array('FirstName:PartialMatch' => $query));
  22.  
  23.                         $Suggestions = array();
  24.                         foreach($Results as $member) {
  25.                                 $Suggestions[] = $member->Name . ' (' . $member->Email . ')';
  26.                         }
  27.  
  28.                         $json = array('query' => $query, 'suggestions' => $Suggestions);
  29.  
  30.                         return Convert::raw2json($json);
  31.                 }
  32.  
  33.                 $this->redirect($this->Link());
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement