public function forSelection() { $field = $this->input->get('value', '_id', 'default'); $term = $this->input->get('q', null, 'default'); $key = new \MongoRegex('/' . $term . '/i'); $where = array(); $where[] = array('username' => $key); $where[] = array('email' => $key); $where[] = array('first_name' => $key); $where[] = array('last_name' => $key); $results = \Shop\Models\Customers::forSelection(array('$or' => $where), $field); $response = new \stdClass(); $response->more = false; $response->term = $term; $response->results = $results; return $this->outputJson($response); }
dataType: 'json', data: function (term, page) { return { q: term }; }, results: function (data, page) { return {results: data.results}; } } <?php if ($state->get('filter.user')) { ?> , initSelection : function (element, callback) { var data = <?php echo json_encode(\Shop\Models\Customers::forSelection(array('_id' => new \MongoId($state->get('filter.user'))))); ?> ; callback(data); } <?php } ?> }); }); </script> <div class="row"> <div class="col-md-2">