No Code Attached Yet Documentation Required J3 Issue
avatar ThomasK0lasa
ThomasK0lasa
18 Sep 2018

Steps to reproduce the issue

As stated here: https://docs.joomla.org/SQL_form_field_type

This (the sql_filter) won't work when used in plugin xml file:

<field name="groups"
    type="sql"
    label="COM_EXAMPLE_GROUPS"
    sql_select="e.*"
    sql_from="#__example_groups AS e"
    sql_group="name"
    sql_order="e.id ASC"
    key_field="id"
    value_field="name"
/>

<field name="subgroups"
    type="sql"
    label="COM_EXAMPLE_SUBGROUPS"
    sql_select="e.*"
    sql_from="#__example_subgroups AS e"
    sql_group="name"
    sql_order="e.id ASC"
    sql_filter="groups"
    key_field="id"
    value_field="name"
/>

Expected result

Loaded data in second field based on selection in first field and sql_filter.
Or at least add an exception to documentation that this type of field doesn't support sql_filter when used in plugins.

Actual result

No data is loaded.

System information (as much as possible)

PHP Built On Windows NT DESKTOP-3H70E5I 10.0 build 17134 (Windows 10) i586
Database Type mysql
Database Version 5.5.5-10.1.32-MariaDB
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 7.2.5
Web Server Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.5
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.8.12 Stable [ Amani ] 28-August-2018 14:00 GMT
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

Additional comments

Problem is in libraries\joomla\form\fields\sql.php - the sql field type dosen't support plugin params at all.
Line 229: $html_filters = JFactory::getApplication()->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array');

avatar ThomasK0lasa ThomasK0lasa - open - 18 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Sep 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Sep 2018

Can a experienced one please comment on this Issue as its open fpr a Week having Status "New"?


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Sep 2018
Status New Information Required
avatar Fedik
Fedik - comment - 26 Sep 2018

I think it need a "real life example" (how the field definition looks in your XML) to see what exactly is going on. Without this it is hard to reproduce.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Sep 2018

Thanks for Comment @Fedik

@ThomasK0lasa can you please give an Example as Fedik wrote above?

avatar ThomasK0lasa
ThomasK0lasa - comment - 26 Sep 2018

I will prepare an example, but give me some time - overloaded with work lately. Is this ok @franz-wohlkoenig and @Fedik?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 Sep 2018

Sure.

avatar brianteeman brianteeman - change - 30 Oct 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 30 Oct 2018
avatar hakanara
hakanara - comment - 22 Feb 2019

This issue is still open. We can call this functionality as dependant SQL fields. When you select the value from the first listbox, the second listbox is supposed to be updated automatically.

Just to make it more clear, I quote the explanation that I copied from docs.joomla.org/SQL_form_field_type:

<field name="groups"
    type="sql"
    label="COM_EXAMPLE_GROUPS"
    sql_select="e.*"
    sql_from="#__example_groups AS e"
    sql_group="name"
    sql_order="e.id ASC"
    key_field="id"
    value_field="name"
    /> 

but the subgroups field includes an sql_filter attribute which refers to the groups field by name:

<field name="subgroups"
    type="sql"
    label="COM_EXAMPLE_SUBGROUPS"
    sql_select="e.*"
    sql_from="#__example_subgroups AS e"
    sql_group="name"
    sql_order="e.id ASC"
    sql_filter="groups"
    key_field="id"
    value_field="name"
    />

Then if the groups field has the value 99, the following SQL statement will be executed for the subgroups field:

SELECT e.* FROM jos_example_subgroups AS e WHERE groups = 99 GROUP BY name ORDER BY e.id ASC

But it doesn't work like that at all. Not only in plugins but in any kind of XML (for menus or modules as well). I checked it with the latest Joomla version which is 3.9.3.

Maybe someone hears us. You can also read more here about the same problem which is still unsolved:
joomla.stackexchange.com/questions/17886/joomla-3x-sql-field-not-filtering-on-change

avatar ThomasK0lasa
ThomasK0lasa - comment - 24 Feb 2019

I am sorry but I don't have time to create proper example. :(

avatar hakanara
hakanara - comment - 24 Feb 2019

@ThomasK0lasa and @franz-wohlkoenig , I think the example above that I took from Joomla docs is more than enough. Isn't it? What kind of example do you need? Maybe I can prepare it?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

@Fedik wanted the Example #22241 (comment)

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Mar 2019

@Fedik can you please comment #22241 (comment)?

avatar Fedik
Fedik - comment - 17 Mar 2019

well,
First. sql_from="#__example_subgroups AS e" - this is not real life example, because Joomla! do not have example_subgroups table. But it do not need anymore.

Second. the field expect request filter parameter (in $_GET or $_POST) , eg &filter[group]=99.
(This would be good to clarify in documentation)

This (the sql_filter) won't work when used in plugin xml file

This won't work anywhere, without filter parameter in request.

Third.

When you select the value from the first list-box, the second list-box is supposed to be updated automatically.

it is not supposed to be automatically. This part you need to code on your own (eg use onchange on first input).

I think this more like a feature request, but not a bug.

avatar hakanara
hakanara - comment - 17 Mar 2019

@Fedik , I don't know who you are and how you tell all these but if I compare what you wrote above with the Joomla documentation, what you write and what the documentation say does not match at all. Either you are wrong or the documentation. You say it is a feature request but the documentation says it already works as described. It does not even say anything about the limitations or the usage way you mentioned above. So, sorry, I still take it as a bug unless the documentation is changed.

Please reread the bottom of this page:
docs.joomla.org/SQL_form_field_type

avatar Fedik
Fedik - comment - 17 Mar 2019

@hakanara pleas reread my previous comment. Pay attention on:

Second. the field expect request filter parameter (in $_GET or $_POST) , eg &filter[group]=99.
(This would be good to clarify in documentation)

avatar jcodewalker
jcodewalker - comment - 1 Apr 2019

@Fedik if it really works like you say the form doesn't need the "groups" field at all, since the filter parameter is passed via GET or POST "subgroups" field works anyway. The same result can be obtained with a custom field. We can say this is a way to xml a custom (simply) list field...

avatar franz-wohlkoenig franz-wohlkoenig - change - 10 Apr 2019
Labels Added: ?
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 10 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 10 Apr 2019
Category Administration com_plugins Documentation Fields Libraries Plugins Administration com_plugins Fields Libraries Plugins
avatar fastslack
fastslack - comment - 30 Apr 2019

This PR solve this problem: #24755

avatar ghost
ghost - comment - 30 Apr 2019

Closed as having Pull Request. Thanks for comment @fastslack

avatar franz-wohlkoenig franz-wohlkoenig - change - 30 Apr 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-04-30 07:13:55
Closed_By franz-wohlkoenig
avatar franz-wohlkoenig franz-wohlkoenig - close - 30 Apr 2019
avatar joomla-cms-bot joomla-cms-bot - change - 15 Jun 2019
Status Closed New
Closed_Date 2019-04-30 07:13:55
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - reopen - 15 Jun 2019
avatar Quy Quy - change - 15 Jun 2019
Status New Confirmed
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot
joomla-cms-bot - comment - 15 Jun 2019

Set to "open" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/22241

avatar ayazbaloch
ayazbaloch - comment - 28 Jun 2019

Also is not working in Admin component in edit and filter mode. Real life example is Region, Country and city.

avatar hakanara
hakanara - comment - 29 Jun 2019

Yes, it doesn't work for this issue. Maybe the PR solved the other issue, I don't know but the dependant SQL fields still do not work as described. Neither in menus in the admin as well.

avatar ReLater
ReLater - comment - 29 Jun 2019

I think the example above that I took from Joomla docs is more than enough. Isn't it?

No, it isn't.

What kind of example do you need?

One that works with Joomla core tables and can be easily implemented by a Joomla core hack in a test site.

So, sorry, I still take it as a bug unless the documentation is changed.

It's not a bug just because the documentation is incomplete.

Feel free to adapt the docs! The docs site is a public Wiki site that lives on community input, corrections and additions. I myself don't have any idea what you all are talking about here. Thus i'm not able to do anything helpful there.

I would suggest to open a feature request or "bug-fixing" pr for Joomla 4 if you think it's worth it.

avatar hakanara
hakanara - comment - 29 Jun 2019

I will open a new feature request or a new issue with the core Joomla tables. Thank you for your time @ReLater. I think having this dependant SQL fields feature will be beneficial for Joomla community. I send my love to each person who spares their time for Joomla.

avatar ayazbaloch
ayazbaloch - comment - 29 Jun 2019

May be users just like me doing wrong, could any guideline how we achieve this, mean how cascade drop-down work.

avatar ayazbaloch
ayazbaloch - comment - 9 Jul 2019

Dear Joomla community, could any one update when will this issue will be solved, this will help new joomla developers like me.

avatar ghost
ghost - comment - 9 Jul 2019

@ayazbaloch there is no Pull Request by a Volunteer so this Issue is unsolved.

avatar ayazbaloch
ayazbaloch - comment - 9 Jul 2019

Dear @franz-wohlkoenig , could it assign to joomla core developers?

avatar ghost
ghost - comment - 9 Jul 2019

all Developers are Volunteers, no one can assign anything to anybody. Best Way to solve a Issue is to do it by your own if you have the skills. If not it take time if a Developer ist interested to make a Pull Request.

avatar brianteeman
brianteeman - comment - 9 Jul 2019

If you add the following to the first field does it work?

onchange="this.form.submit()"

avatar brianteeman
brianteeman - comment - 9 Jul 2019

also the value of sql_filter has to match the column name because it is producing a query in the form of where sql_filter=value so you might need to rename your first field to ensure its a valid column

avatar Fedik
Fedik - comment - 9 Jul 2019

@brianteeman in some reason, people expect that this should work like https://jsfiddle.net/mplungjan/65Q9L/
but it is not, it totally different thing

avatar ayazbaloch
ayazbaloch - comment - 9 Jul 2019

Dear @brianteeman, I did it and it refresh parent field to change 1st value and not filter the dependent(child) field, if we have done the following issue link, it filters only filter first loaded parent value but not others selected values.
#22859

avatar brianteeman
brianteeman - comment - 9 Jul 2019

@Fedik from the docs I would expect that too

avatar jcodewalker
jcodewalker - comment - 9 Jul 2019

everyone would expect to work like that…

The most alarming phrase is "all Developers are Volunteers, no one can assign anything to anybody. Best Way to solve a Issue is to do it by your own if you have the skills. If not it take time if a Developer ist interested to make a Pull Request.”
It seems like there is an anarchy in software development and not a general project with a project leader (team, board or single person), which assign priority (at least) to developer grouped by tech area (at least).

Cascading depending fields (or filtered fields or whatever you like) is something that should have been included since v1.6, from my point of view, as it fix a main issue in a full address registration form (to start with), something that is not so rare…
Not to mention this would empower the use of the relational database.

But here we are, still discussing about a basic feature in hope of the inspiration of some bored developer… while the classes have been changed... I can’t remember the number of time…
Let me say what a depressing image.

Il giorno 09/lug/2019, alle ore 12:57, Brian Teeman notifications@github.com ha scritto:

@Fedik https://github.com/Fedik from the docs I would expect that too


You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/joomla/joomla-cms/issues/22241?email_source=notifications&email_token=ALWXFT7QVYUEHDUF5WBERITP6RVJFA5CNFSM4FV2II42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP46NA#issuecomment-509595444, or mute the thread https://github.com/notifications/unsubscribe-auth/ALWXFT6P4LEKTUN3CF66BZ3P6RVJFANCNFSM4FV2II4Q.

avatar brianteeman
brianteeman - comment - 9 Jul 2019

@jcodewalker where do i send your refund to

avatar jcodewalker
jcodewalker - comment - 9 Jul 2019

@brian Teeman
Unfortunately there is not any price you can pay for the time of our lives we spent over Joomla’s bugs and not with our families.

Your question is very disrespectful toward every users/developers, their time, their lives, their families.
Last but not least, is not constructive

Instead, if the Joomla’s community want, I’m available to spend some time of my life to give to the community a structure and drive you to be a more professional team, more effective, time saving (yours, users and developers), and everybody will benefit of it. That’s is my true work, programming is only an hobby for me.

Let me know.

Il giorno 09/lug/2019, alle ore 14:26, Brian Teeman notifications@github.com ha scritto:

@jcodewalker https://github.com/jcodewalker where do i send your refund to


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/joomla/joomla-cms/issues/22241?email_source=notifications&email_token=ALWXFT53DWVXNGA4MB5EISTP6R7W5A5CNFSM4FV2II42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQDHXY#issuecomment-509621215, or mute the thread https://github.com/notifications/unsubscribe-auth/ALWXFTYSAQFNMA2JAHBZKWDP6R7W5ANCNFSM4FV2II4Q.

avatar brianteeman
brianteeman - comment - 9 Jul 2019

Perhaps you realise why your own comment was disrespectful to the hard work and unpaid hours of everyone who actually contributes.

avatar jcodewalker
jcodewalker - comment - 10 Jul 2019

@brian Teeman
It was not at all.
It was a comment to the picture you defined. If it’s not true you are giving an abominable image of all the Joomla community and you are disrespectful toward all the contributors.
You know if the picture you described is true or not, what doesn’t change is the fact you are disrespectful toward someone.

My offer is still on the table.

Il giorno 09/lug/2019, alle ore 20:38, Brian Teeman notifications@github.com ha scritto:

Perhaps you realise why your own comment was disrespectful to the hard work and unpaid hours of everyone who actually contributes.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/joomla/joomla-cms/issues/22241?email_source=notifications&email_token=ALWXFT3MWN5OVUTUMXLBSZTP6TLMHA5CNFSM4FV2II42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZREXEI#issuecomment-509758353, or mute the thread https://github.com/notifications/unsubscribe-auth/ALWXFT72WVNNK67PZQVMKUTP6TLMHANCNFSM4FV2II4Q.

avatar fastslack
fastslack - comment - 10 Jul 2019

To fix this issue, just apply this patch https://github.com/joomla/joomla-cms/pull/24755/files or simply replace the libraries/joomla/form/fields/sql.php file with this:

https://raw.githubusercontent.com/fastslack/joomla-cms/669b6c992f41edee453796ca00a0bc695dbf776c/libraries/joomla/form/fields/sql.php

I ll try to have a PR soon

avatar ayazbaloch
ayazbaloch - comment - 10 Jul 2019

Dear @fastslack, I copied it and retest it but not desire result. Could any special instruction to test it.

avatar fastslack
fastslack - comment - 10 Jul 2019

Here are some initial test instructions, if this not work, I ll to look this deeper soon

#24755

avatar ayazbaloch
ayazbaloch - comment - 11 Jul 2019

Dear @fastslack I tested no desire result found, kindly look this at your end may be I am doing wrong.

avatar ayazbaloch
ayazbaloch - comment - 20 Jul 2019

Dear @fastslack sorry to disturb you, could you explain your statement where I could not get your point in #24755 . Here is your statement in bracket (Yes, I tested it and seems that work better using getUserState. User can change the filter in their views using:

$app->setUserState("com_example.list_view_example.filter.catid", $filterCategories);
If we use getUserStateFromRequest, when the use select one item from the fields, it cleanup all filters and do not get the current filtering. It return empty values) Please explain me I am sure I am doing something wrong.

avatar aDaneInSpain
aDaneInSpain - comment - 28 Aug 2019

I have updated the documentation to reflect that this feature does not work. https://docs.joomla.org/SQL_form_field_type

avatar Fedik
Fedik - comment - 28 Aug 2019

It misunderstanding in "how it work", and not "it does not work"

avatar aDaneInSpain
aDaneInSpain - comment - 29 Aug 2019

It misunderstanding in "how it work", and not "it does not work"

No it is not. The documentation details how this feature should work... but it doesn't.

Someone will hopefully make a pull request to make it work as it is a pretty essential part of making an interface.

This is reported and marked as a bug. Unless this is changed to a feature request the warning "It does not work" that I added to the documentation is correct.

avatar Fedik
Fedik - comment - 30 Aug 2019

No it is not.

yes, it is

... this feature should work... but it doesn't

About an original issue, please see my comment #22241 (comment) I already explained what wrong here.

Documentation made from the code, not the code from the documentation.

In documentation people see thing that not exist there.
Example:

Loaded data in second field based on selection in first field and sql_filter.

Actually the result will be loaded only after pager reload, when first <select> are changed and the form was submit.
This part not clear in documentation, and everyone assume that a second <select> should be reloaded magically when first <select> was changed. (btw, Joomla! even do not have API for that)

If people want "reloaded magically" then this is a feature request.

And another missed thing in the documentation that the field expect a request parameter filter to work (this is documentation issue).

avatar aDaneInSpain
aDaneInSpain - comment - 30 Aug 2019

When the status of this issue is changed to a feature request then we can update the documentation accordingly.

Until then, it is marked as a bug. And in my opinion it is a bug as one of the main points of the extended SQL query was to enable this functionality.

avatar Fedik
Fedik - comment - 30 Aug 2019

the main points of the extended SQL query was to enable this functionality

the main points of the extended SQL query is to allow to use SQL query, not to produce a magic 😉

avatar aDaneInSpain
aDaneInSpain - comment - 30 Aug 2019

the main points of the extended SQL query is to allow to use SQL query

That was already possible with the original implementation.

avatar alikon alikon - change - 13 Nov 2022
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2022-11-13 08:02:02
Closed_By alikon
Labels Added: No Code Attached Yet Documentation Required
Removed: ? ?
avatar alikon alikon - close - 13 Nov 2022
avatar alikon
alikon - comment - 13 Nov 2022

i don't trust in magic
i trust in sql
🤣

avatar jbrailas
jbrailas - comment - 15 Mar 2024

The following file should be replaced for sql_filter to work in Joomla 5. ( path: libraries/src/Form/Field/SqlField.php )
Can someone notify the core developers?
SqlField.zip

Add a Comment

Login with GitHub to post a comment