Skip to content
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

[5.2] ModalSelect: selecting the title for the field value, when possible #43746

Merged
merged 6 commits into from
Aug 9, 2024

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Jul 6, 2024

Pull Request for Issue # .

Summary of Changes

As for now ModalSelect does not able to display the title for selected value, after saving.
This PR add a posibility to do it.
To make it work, the field XML should have 3 attributes:

  • sql_title_table The table wehre the title is stored
  • sql_title_column The column name in that table
  • sql_title_key The column name that represent the field value, for the "where" query.

Testing Instructions

Add ModalSelect field in to Custom HTML module:

<field
  type="ModalSelect"
  name="article"
  label="Article"

  select="true"
  titleSelect="Selecting the Article"
  urlSelect="index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component"
  clear="true"
  
  sql_title_table="#__content"
  sql_title_column="title"
  sql_title_key="id"
/>

Go to the module editing, and select any article with this field, and save the module.

Actual result BEFORE applying this Pull Request

After saving the field display the article ID

Expected result AFTER applying this Pull Request

After saving the field display the article title

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

@Quy
Copy link
Contributor

Quy commented Jul 9, 2024

I have tested this item ✅ successfully on be34f77


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

1 similar comment
@robbiejackson
Copy link

I have tested this item ✅ successfully on be34f77


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

@robbiejackson
Copy link

The only issue is that both the id field and the title field are sent in the POST parameters when the form is submitted, which looks rather peculiar, but works I think because the title field is sent first, and it somehow then gets overwritten by the id field (maybe in the processing by the PHP processor).

What about setting the title field as disabled? I believe it won't then get submitted.

Or at least provide an option to disable the title field.

@Fedik
Copy link
Member Author

Fedik commented Jul 26, 2024

@robbiejackson thanks for feedback.
This was made for purpuse. For accessibility. Because the field linked to the label by for attribute.

In the normal form we probably could just remove name attribute from the title field. However in the subform field, this field will lost connection with its label, due to how subform work (it calculate id of the input based on its name, and latter looking for the label for attribute ).

The browser will submit both, but the latter one will overide first one, so here is no problem.

@robbiejackson
Copy link

Ah, ok, thanks for the explanation Fedik.

@Quy
Copy link
Contributor

Quy commented Jul 26, 2024

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 26, 2024
@pe7er pe7er self-assigned this Aug 8, 2024
@pe7er pe7er merged commit ac7ecfd into joomla:5.2-dev Aug 9, 2024
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 9, 2024
@pe7er
Copy link
Contributor

pe7er commented Aug 9, 2024

Thanks @Fedik !

@Fedik Fedik deleted the content-select-field-load-title branch August 9, 2024 11:07
@Quy Quy added this to the Joomla! 5.2.0 milestone Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants