As noticed in #5004 the JFormFieldUser field was ready to accept "groups" and "exclude" filters, but the code was actually never completed.
In JFormFieldUser class there are two functions:
protected function getGroups() { return null; }
protected function getExcluded() { return null; }
Function getInput() invoke both this methods which is totally pointless because it always assign null values to this variables:
$groups = $this->getGroups();
$excluded = $this->getExcluded();
Then this always null parameters are passed to com_users&view=users&ayout=modal view which is working pretty nice when you provide some values. For example when getGroups function is recoded to:
protected function getGroups()
{
if(isset($this->element['filter'])) {
return explode(',', $this->element['filter']);
}
return null;
}
``` using filtering field in form file like:
allows to show only users from particular user groups in modal because this filtering option is already implemented in this view (without hiding filter field).
# Testing Instructions
1) Apply the patch
2) Add a new User in Joomla and place in in a group (like Authors)
3) Open the form file of an existing component (like /administrator/components/com_contact/models/form/contact.xml)
4) Find the field with "type=user" in that file
5) Add an attribute "groups" to that xml field and place a csv list of user groups ids
6) Add an attribute "exclude" to that xml field and fill it with a csv list of user ids you want to exclude
7) Try creating a new contact from com_contact and check if selecting the user you see only the users in the "groups" and that are not "excluded"
Can you please add the test instructions. Thank you.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5027.