-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.4] Fix SQL field, get the filter value from the linked filter field #43789
Conversation
I've updated the documentation for the SQL form field to describe the Linked Field feature at http://pr-278.manual.joomlacode.org/docs/next/general-concepts/forms-fields/standard-fields/sql#linked-fields-as-filters (it's not yet merged into the Joomla Manual). The documentation uses the example of a category field, and a SQL field which displays the titles of articles whose category matches that of the category field. The documentation includes (at the bottom of the page) a link to a component com_sqlfield which can be downloaded and adapted for testing this PR. The current version of the SQL field uses the user state to pass the linked field id to the SQL field (eg the category id to the SQL field displaying the list of titles). This involves:
It's a lot easier for the user if the SQL field code gets the linked field id from the Form object, rather than requiring the user to explicitly pass it in a state variable. The com_sqlfield component still works when this PR is applied, showing that if someone has used the user state method to implement this feature then it should be backward compatible. To test this PR I removed the 'context' attribute from the sql field in the xml form, and the setting of the "sqlfield.filter" state in the SqlfieldController and the component worked ok. I'll update the documentation if this PR gets merged. |
I have tested this item ✅ successfully on 1febcaf This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43789. |
I have tested this item ✅ successfully on 1febcaf This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43789. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43789. |
Thank you! |
joomla#43789) * Fix SQL field, get the filter value from the linked filter field * cs * esc ---------
joomla#43789) * Fix SQL field, get the filter value from the linked filter field * cs * esc ---------
Summary of Changes
Due to bug in SQL field the feature "Linked Fields as Filters" is broken.
The PR is fixing this feature, by using the value directly from the form.
Use of the value from Request should be deprecated in future.
Thanks @robbiejackson for the idea and code. I just copy pasting it in to the PR :)
Testing Instructions
Add folowing field in to Custom HTML module:
Create and save new Custom HTML module, or open existing.
Change the value of "Category" field.
After selecting new value and saving the form, the linked Article field should display only articles from the selected category.
Actual result BEFORE applying this Pull Request
The Article field shows ALL articles.
Expected result AFTER applying this Pull Request
The Article field shows only the articles froms the selected category.
Link to documentations
Please select: