?
avatar YatharthVyas
YatharthVyas
19 Apr 2021

Steps to reproduce the issue

  1. Visit Joomla Admin Panel
  2. Plugins -> User - Joomla API Token
  3. If Super User is selected then clear it, select another group and save
  4. Clear out the selection (Ctrl + Click on the selected item)
  5. Save
  6. Refresh / Check the database table

Expected result

The field should attain the default value, ie. Super Users (ID: 8)

image

Actual result

Defaults to the previously selected item(s) (Administrator in the case of the gif below)

image

result

System information (as much as possible)

image

Additional comments

Discovered while testing #33188 (Issue still persists after changing the layout)

The default value for this field in the XML seems to be fine.

If I clear the value in the database table directly then the input field selects Super User (ID: 8) by default on save. But after selecting a different user group, this bug is again reproducible.

If multiple fields were selected before then all of them are retained. (No updation)

avatar YatharthVyas YatharthVyas - open - 19 Apr 2021
avatar joomla-cms-bot joomla-cms-bot - change - 19 Apr 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Apr 2021
avatar YatharthVyas YatharthVyas - change - 19 Apr 2021
The description was changed
avatar YatharthVyas YatharthVyas - edited - 19 Apr 2021
avatar YatharthVyas YatharthVyas - change - 19 Apr 2021
The description was changed
avatar YatharthVyas YatharthVyas - edited - 19 Apr 2021
avatar richard67
richard67 - comment - 19 Apr 2021

@YatharthVyas That's how form validation works in Joomla (at least in 4), as far as I know. If there is a field which has an invalid value, and I'd assume an empty group ID field is such a case, then the form is not saved, so all previous values are retained.

This makes sense since there might be interdependencies between fields regarding data, so it could lead to an inconsistent result if you just set one field back to the default and save the changes for the others.

Ok, this case here might be a bad example, but I think you get what I mean.

So for me the issue here is not that the changed form data is not saved and the previous form data is retained instead of using the default.

For me the issue is that there is no validation message ("Invalid field Allowed User Groups" error alert) shown, or it is shown only for a short time and then hidden by the "Plugin saved." success alert, that can also be. And at the end the "Plugin saved." success alert is shown, which should not be the case.

But I might be wrong or missing something, so lets see if other opinions drop in.

avatar richard67
richard67 - comment - 19 Apr 2021

Thinking more about it, I don't see any issue. Clearing the field with selecting it while CTRL key pressed is nothing which a user would want to do, and if that happens, it's ok for me that the field changes back to the previous selection when saving.

avatar YatharthVyas
YatharthVyas - comment - 19 Apr 2021

It makes sense now. Thanks for the insight @richard67 . I'll close the issue for now and if need be, it can always be re-opened.

avatar YatharthVyas YatharthVyas - change - 19 Apr 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-04-19 17:51:21
Closed_By YatharthVyas
avatar YatharthVyas YatharthVyas - close - 19 Apr 2021
avatar Fedik
Fedik - comment - 20 Apr 2021

Defaults to the previously selected item

This is how <select multiple> works, if all items is unchecked then the browser do not send anything to server, and so on server stays old value.
The same behavior for checkboxes, if they unchecked then the browser do not send anything to server.

avatar Fedik
Fedik - comment - 20 Apr 2021

@YatharthVyas if you like you can make a PR to make this field "required", this should help to avoid such cases

Add a Comment

Login with GitHub to post a comment