Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ....
- $formfields = array('1','2','3','4');
- foreach ($formfields as $value) {
- if($data['ExistingMemberName' . $value] != ''){
- // If they selected an existing member look them up and select the first in the list
- // This assumes that only 1 person by that name is in the system...
- $member = Member::get()
- ->filter(array(
- 'FirstName' => preg_replace("/\([^)]+\)/","",$data['ExistingMemberName' . $value])))
- ->first();
- // Adds the exisiting member to the team
- $team->Members()->add($member);
- .....
- public function results() {
- if($query = $this->getSearchQuery()) {
- //Search for our query - Pretty basic example here
- $Results = Member::get()->filter(array('FirstName:PartialMatch' => $query));
- $Suggestions = array();
- foreach($Results as $member) {
- $Suggestions[] = $member->Name . ' (' . $member->Email . ')';
- }
- $json = array('query' => $query, 'suggestions' => $Suggestions);
- return Convert::raw2json($json);
- }
- $this->redirect($this->Link());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement