joomla-cms
joomla-cms copied to clipboard
[5.1] Add onchange option to modal-select form field
Summary of Changes
I noticed that the layout of the modal-select form field declares the $onchange option, but does not use it. This PR fixes that. I'm not sure if this is a new feature or a bugfix, since it fixes a broken behavior, but could also be judged as a new feature? I created it for 5.1 for now.
Testing Instructions
Edit a filter form like administrator/components/com_content/forms/filter_articles.xml and add a modal select field here. One example would be the following:
<field
name="test"
type="article"
label="COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL"
required="true"
select="true"
new="true"
edit="true"
clear="true"
onchange="this.form.submit();"
/>
(You have to add addfieldprefix="Joomla\Component\Content\Administrator\Field" to the <fieldset> of that XML, too.)
Go to the article list view in the backend and select an article from the modal.
Actual result BEFORE applying this Pull Request
Article is selected, nothing happens otherwise.
Expected result AFTER applying this Pull Request
Article is selected, the filter form is submitted and the page is reloading. (Since there is no filter for this on the server side, the request doesn't change anything, but the onchange event is properly fired.)
Link to documentations
Please select:
-
[ ] Documentation link for docs.joomla.org:
-
[X] No documentation changes for docs.joomla.org needed
-
[ ] Pull Request link for manual.joomla.org:
-
[X] No documentation changes for manual.joomla.org needed
We should not use inline javascript anymore
Sure, but as long as we have this option everywhere else, we should also keep it consistent.
I have tested this item :white_check_mark: successfully on 992cc09e24e1e419808c8d6991a45a2f6c4c28b3
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43618.
I have tested this item :white_check_mark: successfully on 992cc09e24e1e419808c8d6991a45a2f6c4c28b3
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43618.
RTC
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43618.
Thanks.
@Hackwar could you do a PR to deprecate all this inline stuff and think about a proper implementation?