Autocomplete not working.. 404

Hey,

i found a Autocomplete Snippet here in this Forum and I tried to use it for my purpose but its not working. I tried to autocomplete the email address but it says:

toolbar.js?1627302522:91 GET http://localhost/users/get-ajaxlist?term=test 404 (Not Found)

UsersController:
public function getAjaxList()
{
$this->autoRender = false;

if ($this->request->is('ajax')) {
    
    $name = $this->request->getQuery('term');
    $results = $this->Users->find('all', [
        'conditions' => ['email LIKE' => $name . '%'],
        'limit' => 10,
        'fields'=>['id','email']
    ]);
    // debug($results);
    $resultsArr = [];
    
    foreach ($results as $result) {
        $resultsArr[] =['label' => $result['email'], 'value' => $result['id']];
    }
    
    return $this->response->withType('application/json')->withStringBody(json_encode($resultsArr));
}

}

index.php

<?= $this->Form->create(null,['type'=>'get']) ?>
 <?= $this->Form->control('email', ['type' => 'text', 'autocomplete' => 'off']); ?>
<?= $this->Form->submit() ?>
<?= $this->Form->end() ?>

javascript:

$(document).ready(function(){

jQuery('#email').autocomplete({
    source:'<?= $this->Url->build([ "controller" => "Users", "action" => "getAjaxlist"],["fullBase" => true,]); ?>',
    minLength: 2,
    delay:0,
    select: function(event, ui) {
            event.preventDefault();
            $("email").val(ui.item.label);
    },


    focus: function(event, ui) {
            event.preventDefault();
            $("#email").val(ui.item.label);
    }
});

});

Database:

CREATE TABLE users (
id int(10) UNSIGNED NOT NULL,
email varchar(255) DEFAULT NULL,
password varchar(255) DEFAULT NULL,
created datetime DEFAULT NULL,
modified datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

If your function name is getAjaxList, I think the URL would be get-ajax-list, not get-ajaxlist. Your “action” in your JavaScript is “getAjaxlist”, which doesn’t match your actual controller function name.

the autocomplete is working so far… but i dont understand why I have to change it like that… the function is called getAjaxList(). So even the get-ajaxlist was wrong to me!
Now i need to write:
source:’<?= $this->Url->build([ "controller" => "Users", "action" => "getAjax-list"],["fullBase" => true,]); ?>’,

crazy but thank you!

But now I can only use Autocomplete if i say:

$this->Authorization->skipAuthorization();

otherwise with ​:
$this->Authorization->authorize($user);

he says:
{message": “Policy for NULL has not been defined.”, “url”: “/users/get-ajax-list?term=hallo”, “code”: 500, “file”: “/var/www/html/r/vendor/cakephp/authorization/src/Policy/OrmResolver.php”, “line”: 85

ah i see you have to add the policy to the PolicyController:

public function canGetAjaxList(IdentityInterface $user, User $resource)
{
return true;
}

and also edit the function in the UserController:

$user = $this->Users->get($this->request->getAttribute(‘identity’)->getIdentifier(), [
‘contain’ => [‘Details’],
]);

how can I use multiple input fields that depend on each other?

E.g if i want to request the Country, City and the Area but the Autocomplete depends on the Country to get the correct suggestions for the City and so on…

The function is called getAjaxList, so use 'action' => 'getAjaxList' when you build the URL. You had 'action' => 'getAjaxlist', see the difference?

It’s saying there’s no policy for NULL, because you haven’t defined $user. And that’s probably not what you want to pass anyway. The argument given to authorize is the resource that you are authorizing access to, e.g. permission to edit a particular record might check whether you own that record, or are part of a group that is allowed to edit it based on some status or relation. The details of the user are available internally already, you don’t need to pass them here. I can’t say what would make sense for you here, but $user is almost certainly wrong.

To make fields depend on each other, you’ll need to have more JavaScript that pulls values from the form and passes them as part of the URL. There should be lots of tutorials out there about how to do that, it’s nothing Cake-specific.

but the policy function is called ’ canGetAjaxList’ so the authorize argument checks if this user is allowed to get ajax lists…

ok i will check that later because im not that familiar with policies yet! the given policy for articles from the tutorial was simple but for users it seems to be different…

well, i tried to request the profile.name with almost the same code that i used before but this is not working:

Index.php

<?= $this->Form->control('**profile.name**', ['type' => 'text', 'autocomplete' => 'off']); ?>

Javascript:
$(document).ready(function(){

jQuery('#profile-name').autocomplete({
    source:'<?= $this->Url->build([ "controller" => "Users", "action" => "getAjax-list"],["fullBase" => true,]); ?>',
    minLength: 2,
    delay:0,
    select: function(event, ui) {
            event.preventDefault();
            $("profile.name").val(ui.item.label);
    },


    focus: function(event, ui) {
            event.preventDefault();
            $("#profile.name").val(ui.item.label);
    }
});

});

UserController:

public function getAjaxList()
{
$this->autoRender = false;

if ($this->request->is('ajax')) {
    
     ]);
    
    $this->Authorization->skipAuthorization();      
    $name = $this->request->getQuery('term');
    $results = $this->Users->find('all', [
        **'contain' => ['Profiles'],**            '
         **conditions' => ['profile.name LIKE' => $name . '%'],**
        'limit' => 10,
        
        **'fields'=>['id','profile.name']**
    ]);
    //debug($results);

What he says now is:

  1. {message: “SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘profile.name’ in ‘field list’”,…}

  2. code: 500

  3. file: “/var/www/html/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php”

  4. line: 39

  5. message: “SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘profile.name’ in ‘field list’”

  6. url: “/users/get-ajax-list?term=test”

debug($results);

APP/Controller/UsersController.php (line 258 )

object(Cake\ORM\Query) id:0 {’(help)’ => ‘This is a Query object, to get the results execute or iterate it.’‘sql’ => ‘SELECT Users.id AS Users__id, profile.name AS profile__name FROM users Users LEFT JOIN profiles Profiles ON Users.id = (Profiles.user_id) LIMIT 10’‘params’ => []‘defaultTypes’ => [‘Users__id’ => ‘integer’,‘Users.id’ => ‘integer’,‘id’ => ‘integer’,‘Users__email’ => ‘string’,‘Users.email’ => ‘string’,‘email’ => ‘string’,‘Users__password’ => ‘string’,‘Users.password’ => ‘string’,‘password’ => ‘‘Users__created’ => ‘datetime’,‘Users.created’ => ‘datetime’,‘created’ => ‘datetime’,‘Users__modified’ => ‘datetime’,‘Users.modified’ => ‘datetime’,‘modified’ => ‘datetime’,‘Profiles__id’ => ‘integer’,‘Profiles.id’ => ‘integer’,‘Profiles__user_id’ => ‘integer’,‘Profiles.user_id’ => ‘integer’,‘user_id’ => ‘integer’,‘Profiles__name’ => ‘string’,‘Profiles.name’ => ‘string’,‘name’ =>‘Profiles__created’ => ‘datetime’,‘Profiles.created’ => ‘datetime’,‘Profiles__modified’ => ‘datetime’,‘Profiles.modified’ => ‘datetime’,‘Profiles__country_id’ => ‘integer’,‘Profiles.country_id’ => ‘integer’,]‘decorators’ => (int) 0’executed’ => false’hydrate’ => true’buffered’ => true’formatters’ => (int) 0’mapReducers’ => (int) 0’contain’ => [‘Profiles’ => [],]‘matching’ => []‘extraOptions’ => [’ conditions’ => [‘profile.name LIKE’ => ‘test%’,],]‘repository’ => object(App\Model\Table\UsersTable) id:1 {‘registryAlias’ => ‘Users’‘table’ => ‘users’‘alias’ => ‘Users’‘entityClass’ => ‘App\Model\Entity\User’‘associations’ => [(int) 0 => 'Profiles[(int) 0 => ‘Timestamp’,]‘defaultConnection’ => ‘default’‘connectionName’ => ‘default’}}

[ Warning (512)](javascript:void(0);): Unable to emit headers. Headers sent in file=/var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php line=1030 [ CORE/src/Http/ResponseEmitter.php , line 71 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 168 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 197 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 197 ]

{ “message”: “SQLSTATE[42S22]: Column not found: 1054 Unknown column \u0027profile.name\u0027 in \u0027field list\u0027”, “url”: “/users/get-ajax-list?term=test”, “code”: 500, “file”: “/var/www/html\/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php”, “line”: 39 }

The function prototype is canGetAjaxList(IdentityInterface $user, User $resource). The $user passed here does not come from your function call, it comes from the authentication system. The thing that you pass to your authorize call comes into this function in the $resource parameter, and, as I said, is the thing that it checks access to, not the user it’s checking access for.

In your conditions, you need to use Profiles.name, not profile.name. It is aliasing the table name here, in case there might be a join of the table to itself, for example.

works without errors:

  1. Request Method:GET
  2. Status Code:200 OK

but :

  1. {label: null, value: null}, {label: null, value: null}, {label: null, value: null},…]

  2. 0: {label: null, value: null}

  3. 1: {label: null, value: null}

  4. 2: {label: null, value: null}

  5. 3: {label: null, value: null}

  6. 4: {label: null, value: null}

  7. 5: {label: null, value: null}

  8. 6: {label: null, value: null}

  9. 7: {label: null, value: null}

Sounds like the problem now is with building the output. I assume that code has changed some since your original post, as you’re now looking at profile names where before it wasn’t. debug($results) will just show you the Query object, but debug($results->toArray()) will be the actual records, and should shed some light on how you need to go about creating your JSON array.

well i dont know why but now there is even an error again:

code:

index.php

<?= $this->Form->create(null,['type'=>'get']) ?>
<?= $this->Form->control('key',['label' => 'Search','value'=>$this->request->getQuery('key')]) ?>
<?= $this->Form->control('profile.name', ['type' => 'text', 'autocomplete' => 'off']); ?>
<?= $this->Form->submit() ?>
<?= $this->Form->end() ?>

javascript:
$(document).ready(function(){

jQuery('#profile-name').autocomplete({
    source:'<?= $this->Url->build([ "controller" => "Users", "action" => "getAjax-list"],["fullBase" => true,]); ?>',
    minLength: 2,
    delay:0,
    select: function(event, ui) {
            event.preventDefault();
            $("profile.name").val(ui.item.label);
    },


    focus: function(event, ui) {
            event.preventDefault();
            $("#profile.name").val(ui.item.label);
    }
});

});

Controller:

public function getAjaxList()
{
$this->autoRender = false;

if ($this->request->is('ajax')) {
    
    $this->Authorization->skipAuthorization();
      
    $name = $this->request->getQuery('term');
    $results = $this->Users->find('all', [
        'contain' => ['Profiles'],            '
         conditions' => ['Profiles.name LIKE' => $name . '%'],
        'limit' => 10,
      
        'fields'=>['id','Profiles.name']
    ]);
   // debug($results);
    debug($results->toArray());
        
    $resultsArr = [];
    
    foreach ($results as $result) {
        $resultsArr[] =['label' => $result['Profiles.name'], 'value' => $result['id']];
    }
    
    return $this->response->withType('application/json')->withStringBody(json_encode($resultsArr));
}

}

it says:

APP/Controller/UsersController.php (line 259)
[
(int) 0 => object(App\Model\Entity\User) id:0 {
‘id’ => (int) 6
‘profile’ => object(App\Model\Entity\Profile) id:1 {
‘name’ => ‘james’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 1 => object(App\Model\Entity\User) id:2 {
‘id’ => (int) 7
‘profile’ => object(App\Model\Entity\Profile) id:3 {
‘name’ => ‘tester’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
'
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 2 => object(App\Model\Entity\User) id:4 {
‘id’ => (int) 8
‘profile’ => object(App\Model\Entity\Profile) id:5 {
‘name’ => ‘rex’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 3 => object(App\Model\Entity\User) id:6 {
‘id’ => (int) 1
‘profile’ => object(App\Model\Entity\Profile) id:7 {
‘name’ => ‘testerdasd’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
'
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 4 => object(App\Model\Entity\User) id:8 {
‘id’ => (int) 2
‘profile’ => object(App\Model\Entity\Profile) id:9 {
‘name’ => ‘tesddter’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 5 => object(App\Model\Entity\User) id:10 {
‘id’ => (int) 3
‘profile’ => object(App\Model\Entity\Profile) id:11 {
‘name’ => ‘tefarster’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
'
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 6 => object(App\Model\Entity\User) id:12 {
‘id’ => (int) 4
‘profile’ => object(App\Model\Entity\Profile) id:13 {
‘name’ => ‘michel’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
’ => true,
‘id’ => false,
‘profile’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
(int) 7 => object(App\Model\Entity\User) id:14 {
‘id’ => (int) 5
‘profile’ => object(App\Model\Entity\Profile) id:15 {
‘name’ => ‘sebi’
‘[new]’ => false
‘[accessible]’ => [
‘user_id’ => true,
‘name’ => true,
‘created’ => true,
‘modified’ => true,
‘user’ => true,
]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Profiles’
}
‘[new]’ => false
‘[accessible]’ => [
'
’ => true,
‘id’ => false,
‘profile’ => true,

]
‘[dirty]’ => [
]
‘[original]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Users’
},
]
Warning (512): Unable to emit headers. Headers sent in file=/var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php line=1030 [CORE/src/Http/ResponseEmitter.php, line 71]
Warning (2): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [CORE/src/Http/ResponseEmitter.php, line 168]
Warning (2): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [CORE/src/Http/ResponseEmitter.php, line 197]
Warning (2): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [CORE/src/Http/ResponseEmitter.php, line 197][{“label”:null,“value”:6},{“label”:null,“value”:7},{“label”:null,“value”:8},{“label”:null,“value”:1},{“label”:null,“value”:2},{“label”:null,“value”:3},{“label”:null,“value”:4},{“label”:null,“value”:5}]

error comes from the debug… but its not wotking anyway

sorry index.php and javascirpt are looking like that now:

index.php
<?= $this->Form->control('profiles.name', ['type' => 'text', 'autocomplete' => 'off']); ?>

javascript:

$(document).ready(function(){

jQuery('#profiles-name').autocomplete({
    source:'<?= $this->Url->build([ "controller" => "Users", "action" => "getAjax-list"],["fullBase" => true,]); ?>',
    minLength: 2,
    delay:0,
    select: function(event, ui) {
            event.preventDefault();
            $("profiles.name").val(ui.item.label);
    },


    focus: function(event, ui) {
            event.preventDefault();
            $("#profiles.name").val(ui.item.label);
    }
});

});

response is still:

  1. [{label: null, value: 6}, {label: null, value: 7}, {label: null, value: 8}, {label: null, value: 1},…]

  2. 0: {label: null, value: 6}

  3. 1: {label: null, value: 7}

  4. 2: {label: null, value: 8}

  5. 3: {label: null, value: 1}

  6. 4: {label: null, value: 2}

  7. 5: {label: null, value: 3}

  8. 6: {label: null, value: 4}

  9. 7: {label: null, value: 5}

Try:

$resultsArr[] =['label' => $result->profile->name, 'value' => $result->id];

This is pretty obvious once you are familiar with reading the debug output. Get used to Cake’s conventions around how to name tables (profiles) and associations (Profiles), how to reference them in queries (Profiles.field_name), and how to access the resulting properties ($entity->profile is the one profile when it’s a belongsTo or hasOne association; $entity->profiles is an array of profiles when it’s a hasMany or belongsToMany association).

now it shows the names but it just shows everything:

  1. [{label: “james”, value: 6}, {label: “tester”, value: 7}, {label: “rex”, value: 8},…]

  2. 0: {label: “james”, value: 6}

  3. 1: {label: “tester”, value: 7}

  4. 2: {label: “rex”, value: 8}

  5. 3: {label: “testerdasd”, value: 1}

  6. 4: {label: “tesddter”, value: 2}

  7. 5: {label: “tefarster”, value: 3}

  8. 6: {label: “michel”, value: 4}

  9. 7: {label: “sebi”, value: 5}

if i say limit to 1 it still shows james on the first position even if i write michel and if i click on a name on the list it not even use it. i cant select it

Presumably, the term query string is not being sent for some reason. That falls squarely into the jQuery side of things, nothing to do with Cake.

but if I use debug i get:

‘extraOptions’ => [

conditions’ => [
‘Profiles.name LIKE’ => ‘test%’,
],
]

test is what i was entering into the input field…

with debug i get warnings:

[ Warning (512)](javascript:void(0);): Unable to emit headers. Headers sent in file=/var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php line=1030 [ CORE/src/Http/ResponseEmitter.php , line 71 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html/r/vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 168 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html//vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 197 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/cakephp/cakephp/src/Error/Debugger.php:1030) [ CORE/src/Http/ResponseEmitter.php , line 197 ]

[{“label”:“james”,“value”:6,“job”:"asd "},{“label”:“tester”,“value”:7,“job”:“maurer”},{“label”:“rex”,“value”:8,“job”:“maurer”},{“label”:“testerdasd”,“value”:1,“job”:"asd "},{“label”:“tesddter”,“value”:2,“job”:"asd "},{“label”:“tefarster”,“value”:3,“job”:“maurer”},{“label”:“michel”,“value”:4,“job”:"asd "},{“label”:“sebi”,“value”:5,“job”:"asd "}]

What does debug($results->sql()); give you? (You can safely ignore all of the “Cannot modify header” warnings, as those are entirely to be expected based on the fact that you’re generating debug output.)

APP/Controller/UsersController.php (line 260 )

‘SELECT Profiles.name AS Profiles__name, Users.id AS Users__id, FROM users Users LEFT JOIN profiles Profiles ON Users.id = (Profiles.user_id) LIMIT 10’

the condition is missing