RFC Feature PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
11 Aug 2024

Summary of Changes

The PR adds a hidden input to allow to submit an empty value when nothing is selected in list (multiple) and checkbox(-es) fields. Because browser does not submit anything when <select multiple> is empty, and <input type="checkbox"> is unchecked.

For now Developers had to use extra check in their Table or Model, however suggested fix should simplify such things.

Testing Instructions

Install testing component com_testi-1.0.1.zip

Create a new Item with some values in checkboxes and list.
Then try uncheck all and remove all selected values, and save again.

Actual result BEFORE applying this Pull Request

After save the previous valueas are shown as checked/selected.

Expected result AFTER applying this Pull Request

After save everything stays unchecked/unselected.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: TBD
  • No documentation changes for manual.joomla.org needed

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar Fedik Fedik - open - 11 Aug 2024
avatar Fedik Fedik - change - 11 Aug 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2024
Category Layout
avatar crommie crommie - test_item - 24 Aug 2024 - Tested successfully
avatar crommie
crommie - comment - 24 Aug 2024

I have tested this item ✅ successfully on dd5e4ac

Works as described!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43905.

avatar pe7er pe7er - test_item - 24 Aug 2024 - Tested successfully
avatar pe7er
pe7er - comment - 24 Aug 2024

I have tested this item ✅ successfully on dd5e4ac

I tested this PR successfully. I experienced this issue in some of my own custom components, and I'm glad that there's now a solution for that.
Thanks for solving this @Fedik !


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43905.

avatar richard67
richard67 - comment - 24 Aug 2024

@pe7er For setting RTC it is not enough to just add the label on GitHub. It needs to change status in the issue tracker. I will do that now.

avatar richard67 richard67 - change - 24 Aug 2024
Status Pending Ready to Commit
Labels Added: Feature RFC PR-5.2-dev
avatar richard67
richard67 - comment - 24 Aug 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43905.

avatar richard67 richard67 - change - 24 Aug 2024
Labels Added: RTC
avatar cybersalt cybersalt - test_item - 24 Aug 2024 - Tested successfully
avatar cybersalt
cybersalt - comment - 24 Aug 2024

I have tested this item ✅ successfully on a434358

I tested this and it worked.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43905.

avatar HLeithner
HLeithner - comment - 2 Sep 2024

This pull request has been automatically rebased to 5.3-dev.

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
[5.2][RFC] Submit an empty value when nothing is selected in list and checkbox(-es) fields
[5.3] [RFC] Submit an empty value when nothing is selected in list and checkbox(-es) fields
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar laoneo
laoneo - comment - 10 Oct 2024

I like the idea, but I fear that this will break existing extensions as it comes all of the sudden with an empty string. Stuff like if(empty($data['com_fields]['radio'])) will not be true anymore as it contains an array with an empty element. It needs an additional array_filter call then.

avatar richard67
richard67 - comment - 10 Oct 2024

@laoneo Shall I remove RTC?

avatar laoneo
laoneo - comment - 10 Oct 2024

I would say so till we get confirmation that I'm wrong.

avatar richard67 richard67 - change - 10 Oct 2024
Status Ready to Commit Pending
avatar richard67
richard67 - comment - 10 Oct 2024

Back to pending. See previous comments.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43905.

avatar Fedik
Fedik - comment - 10 Oct 2024

@laoneo do you actualy tested it, or it just your theory?

Please test first, it nothing to do with your "radio buttons" example.
Thank you.

avatar Fedik
Fedik - comment - 20 Oct 2024

@laoneo do you provide a proof/example that the PR is breaking something?
Otherwise please set it back to RTC.

avatar rdeutz rdeutz - change - 30 Oct 2024
Labels Added: PR-5.3-dev
Removed: RTC PR-5.2-dev
avatar laoneo
laoneo - comment - 30 Oct 2024

@Fedik I will have a deeper look ASAP. But it is clear that an extra value is sent to the server. Give me some time to proove my statement.

avatar HLeithner
HLeithner - comment - 31 Oct 2024

Is the Postgresql test error related, Screenshot

avatar Fedik
Fedik - comment - 31 Oct 2024

There some issue with test, I think. But not related to changes in this PR.
From screenshot it is clear that the categories are there, but the Test does not see them

cy.visit('/index.php?option=com_content&view=categories');
cy.contains('automated test category 1');
cy.get(':nth-child(1) > .com-content-categories__item-title-wrapper > .com-content-categories__item-title > .badge').contains('Article Count: 1');
cy.contains('automated test category 2');
cy.get(':nth-child(2) > .com-content-categories__item-title-wrapper > .com-content-categories__item-title > .badge').contains('Article Count: 2');

The checker should probably wait when page fully rendered before doing DOM query.
But it just my guess.

UPD, on screenshoot the categories in diferent order than expected by test.

avatar laoneo
laoneo - comment - 1 Nov 2024

I had a look and the returned data when no value is selected (I tested it with list). Then it is an empty string and not an empty array. As an array is expected, it is very likely that it gets casted to an array and then you end up with an array which has one entry, the empty string.
image
image

I'm aware that this is an edge case, but a list field is widely used nowadays and I fear this will break stuff.

avatar Fedik
Fedik - comment - 1 Nov 2024

I see. Thanks for checking.
To me it is a bug in data handling by the "list" custom field. The data should be filtered instead of blind cast to array.

I will look, maybe will make it optional, or will change to 6.0.

We already use the same approach for subform (multiple) field for years, and it works fine.
It is realy a pain to handle this input behaviors.

avatar laoneo
laoneo - comment - 1 Nov 2024

And because we have it since ages, it is really hard to change the behavior without breaking stuff into the wild.

avatar joomla-cms-bot joomla-cms-bot - change - 2 Nov 2024
Category Layout Layout Libraries
avatar Fedik Fedik - change - 2 Nov 2024
The description was changed
avatar Fedik Fedik - edited - 2 Nov 2024
avatar Fedik
Fedik - comment - 2 Nov 2024

I have update the code. Now it is configurable, and disabled by default.
Testing component also updated.

db16d26 2 Nov 2024 avatar Fedik cs
a395658 3 Nov 2024 avatar Fedik cs
avatar laoneo
laoneo - comment - 5 Nov 2024

Based on what for a criteria should the end user enable or disable the flag?

avatar Fedik
Fedik - comment - 5 Nov 2024

When developer want to submit and save empty value. Because browser does not submit any value for these cases.

Check the component I made for testing, try edit administrator/forms/item.xml and remove these flag.
I think you never use these fields before, in your projects, did you? :)

By default these fields just unusable without extra work. This PR is fixing it.

avatar laoneo
laoneo - comment - 5 Nov 2024

Ah sorry, I was on custom fields, but you added the option only to the form elements.

Add a Comment

Login with GitHub to post a comment