[BUG]: usergroup field doesn't work when compiling towards Joomla 4 (works in J3) #1100

Open
opened 2024-03-27 22:16:23 +00:00 by dyvel · 2 comments

What Happened?

I added a field of type usergroup to the demo project look view. When I compile towards Joomla 3, I can see and select the usergroups as expected. However, when I compile towards Joomla 4, the field is just blank.

Steps to reproduce the Bug

Create a field of type usergroup and add it to a view, then compile towards Joomla 4.

Which Joomla version are you compiling in?

3.10.12

Which PHP version are you compiling in?

8.1.27

Which Joomla versions are you targeting?

4

Which PHP version are you targeting?

8.1

Which Web server is JCB running on?

Apache 2.4

Which Relational Database is JCB running on?

MariaDB 10.4

Which OS is JCB running on?

Ubuntu 20.4

Which JCB version are you using?

3.2.0 stable

Which Joomla version is JCB installed on?

Joomla 3

Where in JCB did this issue occur?

Joomla Component(admin_view)

On which browsers did you encounter the issue?

Safari

Additional Comments

No response

### What Happened? I added a field of type usergroup to the demo project look view. When I compile towards Joomla 3, I can see and select the usergroups as expected. However, when I compile towards Joomla 4, the field is just blank. ### Steps to reproduce the Bug Create a field of type usergroup and add it to a view, then compile towards Joomla 4. ### Which Joomla version are you compiling in? 3.10.12 ### Which PHP version are you compiling in? 8.1.27 ### Which Joomla versions are you targeting? 4 ### Which PHP version are you targeting? 8.1 ### Which Web server is JCB running on? Apache 2.4 ### Which Relational Database is JCB running on? MariaDB 10.4 ### Which OS is JCB running on? Ubuntu 20.4 ### Which JCB version are you using? 3.2.0 stable ### Which Joomla version is JCB installed on? Joomla 3 ### Where in JCB did this issue occur? Joomla Component(admin_view) ### On which browsers did you encounter the issue? Safari ### Additional Comments _No response_
dyvel added the
Bug
label 2024-03-27 22:16:23 +00:00
Member

I had the same problem.
After some digging, I find out that this problem is resolvable without coding.
Joomla website: Since Joomla 3.2 use usergrouplist instead.

General steps:

  1. Go to your Joomla website admin where you're using JCB
  2. Then Components > Component Builder > Fieldtypes
  3. Click on New button and create a new Fieldtype base on Joomla Docs / User Group List form field type or use below SQL insert query (change "<db_prefix>" to your db prefix):
INSERT INTO `<db_prefix>__componentbuilder_fieldtype` (`id`, `description`, `name`, `properties`, `short_description`, `params`, `published`, `version`, `hits`, `ordering`, `guid`)
VALUES (45,
		'Field to load a drop down list of available user groups.',
		'Usergrouplist',
		'{\"properties0\":{\"name\":\"type\",\"example\":\"usergrouplist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be usergrouplist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"usergrouplist\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Group List\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Select a group\\\/groups\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"layout\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (translatable) is the layout, for example joomla.form.field.list-fancy-select.\"},\"properties5\":{\"name\":\"checksuperusergroup\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is boolean to omit Super User groups. Values 1 or 0.\"},\"properties6\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the usergroup id of the default selection in the dropdown list.\"},\"properties7\":{\"name\":\"multiple\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) If set to true then allows more than one usergroup to be selected.\"},\"properties8\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the field required true if yes.\"},\"properties9\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\\/\\\/joomla.stackexchange.com\\\/a\\\/17682\\\/2166\"},\"properties10\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field. If omitted this will default to ''inputbox''.\"},\"properties11\":{\"name\":\"labelclass\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"Adding the attribute labelclass adds a CSS class for form field''s label. Source: http:\\\/\\\/joomlacode.org\\\/gf\\\/project\\\/joomla\\\/tracker\\\/?action=TrackerItemEdit&tracker_item_id=28450\"}}',
		'Field to load a drop down list of available user groups.',
		'',
		1,
		1,
		'',
		'',
		'3213a9e4-b1a9-40ae-a5bf-31788bb4e27c');
  1. Go to Component Builder > Fields
  2. Edit fields with type Usergroup. Change their type to Usergrouplist that you just created. Save.
  3. Compile & Enjoy JCB

@Llewellyn, I think this problem could be resolved by adding this insert query to #__componentbuilder_fieldtype multiple insert query in install.mysql.utf8.sql and also adding it to 3.2.0-beta.sql.
I wanted to send a Pull Request to fix this problem. May I? Could you give me Pull Request permission please?
Or you could fix it yourself, that's totally cool too 😀

I had the same problem. After some digging, I find out that this problem is resolvable without coding. [Joomla website](https://docs.joomla.org/Standard_form_field_types): Since Joomla 3.2 use usergrouplist instead. General steps: 1. Go to your Joomla website admin where you're using JCB 2. Then Components > Component Builder > Fieldtypes 3. Click on New button and create a new Fieldtype base on Joomla [Docs / User Group List form field type](https://docs.joomla.org/User_Group_List_form_field_type) or use below SQL insert query (change "<db_prefix>" to your db prefix): ```sql INSERT INTO `<db_prefix>__componentbuilder_fieldtype` (`id`, `description`, `name`, `properties`, `short_description`, `params`, `published`, `version`, `hits`, `ordering`, `guid`) VALUES (45, 'Field to load a drop down list of available user groups.', 'Usergrouplist', '{\"properties0\":{\"name\":\"type\",\"example\":\"usergrouplist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be usergrouplist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"usergrouplist\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Group List\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Select a group\\\/groups\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"layout\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (translatable) is the layout, for example joomla.form.field.list-fancy-select.\"},\"properties5\":{\"name\":\"checksuperusergroup\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is boolean to omit Super User groups. Values 1 or 0.\"},\"properties6\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the usergroup id of the default selection in the dropdown list.\"},\"properties7\":{\"name\":\"multiple\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) If set to true then allows more than one usergroup to be selected.\"},\"properties8\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the field required true if yes.\"},\"properties9\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\\/\\\/joomla.stackexchange.com\\\/a\\\/17682\\\/2166\"},\"properties10\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field. If omitted this will default to ''inputbox''.\"},\"properties11\":{\"name\":\"labelclass\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"Adding the attribute labelclass adds a CSS class for form field''s label. Source: http:\\\/\\\/joomlacode.org\\\/gf\\\/project\\\/joomla\\\/tracker\\\/?action=TrackerItemEdit&tracker_item_id=28450\"}}', 'Field to load a drop down list of available user groups.', '', 1, 1, '', '', '3213a9e4-b1a9-40ae-a5bf-31788bb4e27c'); ``` 4. Go to Component Builder > Fields 5. Edit fields with type Usergroup. Change their type to Usergrouplist that you just created. Save. 6. Compile & Enjoy JCB @Llewellyn, I think this problem could be resolved by adding this insert query to `#__componentbuilder_fieldtype` multiple insert query in `install.mysql.utf8.sql` and also adding it to `3.2.0-beta.sql`. I wanted to send a Pull Request to fix this problem. May I? Could you give me Pull Request permission please? Or you could fix it yourself, that's totally cool too 😀
Owner

Since field_types are all DB maintained we currently do not update existing Installs. We are working on an option to also maintain this the way we do powers. So you have power => [init] and power => [reset] in the the Powers list view, we are planning to add this to the field_types as well but this is not yet finished.

I can fix the Usergrouplist so that it will be correct with new JCB installs, but adding an update script to the install is not the direction we would like to take to resolve this going forward.

And I done not want these kind of links in this area of JCB: http:\\\/\\\/joomlacode.org\\\/gf\\\/project\\\/joomla\\\/tracker\\\/?action=TrackerItemEdit&tracker_item_id=28450

Since field_types are all DB maintained we currently do not update existing Installs. We are working on an option to also maintain this the way we do powers. So you have `power => [init]` and `power => [reset]` in the the **Powers list** view, we are planning to add this to the field_types as well but this is not yet finished. I can fix the `Usergrouplist` so that it will be correct with **new JCB installs**, but adding an update script to the install is **not the direction** we would like to take to resolve this going forward. And I done not want these kind of links in this area of JCB: `http:\\\/\\\/joomlacode.org\\\/gf\\\/project\\\/joomla\\\/tracker\\\/?action=TrackerItemEdit&tracker_item_id=28450`
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1100
No description provided.