RTC bug PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
13 Jul 2024

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:

<field
  name="catid"
  type="sql"
  label="Category"
  sql_select="id, title"
  sql_from="#__categories"
  sql_where="level=1 AND extension='com_content'"
  sql_order="lft"
  key_field="id"
  value_field="title"
  default="2"
  onchange="window['toolbar-apply'].buttonElement.click()"
>
  <option>- Select -</option>
</field>
<field
  name="subcat"
  type="sql"
  label="Article"
  sql_select="id, title"
  sql_from="#__content"
  sql_order="title"
  sql_filter="catid"
  key_field="id"
  value_field="title"
>
  <option>- Select -</option>
</field>

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:

avatar Fedik Fedik - open - 13 Jul 2024
avatar Fedik Fedik - change - 13 Jul 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jul 2024
Category Libraries
avatar Fedik Fedik - change - 13 Jul 2024
Title
[4.0] Fix SQL field, get the filter value from the linked filter field
[4.4] Fix SQL field, get the filter value from the linked filter field
avatar Fedik Fedik - edited - 13 Jul 2024
avatar Fedik Fedik - change - 13 Jul 2024
The description was changed
avatar Fedik Fedik - edited - 13 Jul 2024
0e3ed48 13 Jul 2024 avatar Fedik cs
avatar Fedik Fedik - change - 13 Jul 2024
Labels Added: bug PR-4.4-dev
1febcaf 13 Jul 2024 avatar Fedik esc
avatar robbiejackson
robbiejackson - comment - 14 Jul 2024

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:

  • setting the 'context' attribute on the linked field
  • setting the user state against the <context>.filter in the Controller, to pass the linked field id to the SQL field

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.

avatar robbiejackson robbiejackson - test_item - 20 Jul 2024 - Tested successfully
avatar robbiejackson
robbiejackson - comment - 20 Jul 2024

I have tested this item ✅ successfully on 1febcaf

Just confirming the above tests by following the proper procedure.


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

avatar viocassel viocassel - test_item - 22 Jul 2024 - Tested successfully
avatar viocassel
viocassel - comment - 22 Jul 2024

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.

avatar Quy Quy - change - 22 Jul 2024
Status Pending Ready to Commit
avatar Quy
Quy - comment - 22 Jul 2024

RTC


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

avatar MacJoom MacJoom - change - 5 Aug 2024
Labels Added: RTC
avatar MacJoom MacJoom - change - 5 Aug 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-08-05 14:48:00
Closed_By MacJoom
avatar MacJoom MacJoom - close - 5 Aug 2024
avatar MacJoom MacJoom - merge - 5 Aug 2024
avatar MacJoom
MacJoom - comment - 5 Aug 2024

Thank you!

Add a Comment

Login with GitHub to post a comment