modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 529 forks source link

ExtJS: modx-combo-user doesn't render username but user ID instead when user is preselected #13267

Closed gadgetto closed 5 years ago

gadgetto commented 7 years ago

Summary

Using an extjs modx-combo-user and trying to preselect a user when combo is loaded doesn't render the username but it's ID instead.

Step to reproduce

{
    xtype: 'modx-combo-user'
    ,fieldLabel: _('resource_createdby')
    ,description: '<b>[[*createdby]]</b><br />'+_('resource_createdby_help')
    ,name: 'created_by'
    ,hiddenName: 'createdby'
    ,id: 'modx-resource-createdby'
    ,anchor: '100%'
    ,value: config.record.createdby || MODx.user.id
}

Observed behavior

Doesn't render the username of preselected user but it's ID instead.

Expected behavior

Should render username of the preselected user.

Environment

MODX version: 2.5.4-pl

Can be fixed by adding the following lines to:

https://github.com/modxcms/revolution/blob/2.x/core/model/modx/processors/security/user/getlist.class.php#L35

$id = $this->getProperty('id');
if (!empty($id)) {
    $c->where(array('id' => $id));
}
Jako commented 7 years ago

It looks like all (or most) modx-combo variants have this issue.

gadgetto commented 7 years ago

The template-combo works as expected.

Jako commented 7 years ago

Yes, but it fetches the whole templates with limit:0 for some reason. Seems that the store is filtering the data for the pagination.

sdrenth commented 7 years ago

@gadgetto Is this issue fixed already? I can't seem to reproduce this issue in branch 2.x.

gadgetto commented 7 years ago

You need a big user list > 20 users to reproduce this. I still can reproduce this.

sdrenth commented 7 years ago

@gadgetto Ahh I see, the problem occurs when you have a listbox which has pagination. If you have a value preselected which is being retrieved on page 1 of the listbox options all is fine. However if you have a preselected value which is not being retrieved yet (so its on page 2 or further on in the listbox) the name is not yet retrieved so it is displaying the value instead.

I'm thinking, maybe a render value method should run, which performs an ajax request to retrieve the name for the selected user?

Jako commented 7 years ago

It could be fixed with the code from @gadgetto at the start of this thread.

alroniks commented 5 years ago

Solved. PR is merged.