Create a repeatable subform that contains a field that uses js
You can add this code to mod_article_categories.xml as a test
<field
name="field-name"
type="subform"
label="Subform Field"
multiple="true"
min="1"
max="10"
>
<form>
<fieldset name="basic" addfieldprefix="Joomla\Component\Categories\Administrator\Field">
<field
name="parent"
type="modal_category"
label="MOD_ARTICLES_CATEGORIES_FIELD_PARENT_LABEL"
extension="com_content"
filter="integer"
published=""
select="true"
new="true"
edit="true"
clear="true"
/>
</fieldset>
</form>
</field>
A working repeatable field to select the category
Only the first occurence works. All subsequent fields do not as the modal is empty
I understand that this is because the modal_category field uses javascript to populate the iframe in the body of the modal but as it does this on page load it does not work for the repeated field because it is not present on page load.
I assume that there could be some javascript that could be instantiated when a subform row is added that would populate the field as required. But I don't have a clue with js to know where to start
Labels |
Added:
No Code Attached Yet
|
not suprised that you got no feedback on #39351 as it contained no information about what changed and why.
Looking at it now I still don't know if its just a refactoring or if it indeed resolves the issue I have.
Surely (to my non js dev mind) its just a case of having some js to watch if a new row is added and then do what is necessary to configure the field
@brianteeman you're wrong: #38404 (comment)
and how is anyone supposed to know that? You ddidn't link to 38404 anywhere in 39351
and anyway 38404 is completely unrelated to the issue I am reporting
Surely (to my non js dev mind) its just a case of having some js to watch if a new row is added and then do what is necessary to configure the field
Not really, the fields with a modal need to be client side rendered and not prerendered from the php side. Me an Fedik investigated on the possible solutions:
and how is anyone supposed to know that? You ddidn't link to 38404 anywhere in 39351
I wasn't expecting anyone
to participate on that PR, only the people I mentioned in the issue
and anyway 38404 is completely unrelated to the issue I am reporting
It's the same issue and it's occurring almost in every field that has a modal...
and anyway 38404 is completely unrelated to the issue I am reporting
It's the same issue and it's occurring almost in every field that has a modal...
it is not the same issue. Please re-read what I wrote and not what you think I wrote.
and the site I am testing on does NOT have mod_security enabled!
As Dimitris wrote, almost any modal field will not work in subform.
And other fields that have extra javascript logic, should be coded to work in subform as web component or with this event: https://docs.joomla.org/J4.x:ClientSideEvents#joomla:updated
and thats what I am asking for
Sadly the docs page for ClientSideEvents almost impossible to find in Google.
I still don't know what to do with that information
I assume that there could be some javascript that could be instantiated when a subform row is added that would populate the field as required. But I don't have a clue with js to know where to start
There also some examples in https://docs.joomla.org/Subform_form_field_type
They are old for jquery and need to be updated, but the idea the same.
You basicaly need to run javascript to iniitialise when page is loaded (on DOMContentLoaded) and when new row added (on joomla:updated event.)
Like here example
joomla-cms/build/media_source/system/js/fields/select-colour.es6.js
Lines 41 to 46 in 6798f07
I still don't know what to do with that information
Check the comments from me and @Fedik on another field: #35678 (review)
What I don't understand why you both keep saying things like this instead of it actually being fixed
It's not that easy and involves some sort of B/C break. For example the selecting of a category has a dynamic function (created on PHP at run time) passed in the URL:
This is wrong on every conceivable way but fixing it involves some level of B/C break. These were the kind of solutions we were looking at, both on the discussion and the RFC. Also, whenever a b/c break is required, people get extremely impolite on their responses, so that's also not very motivating to work on such issues.
To fix all that in proper way, need to rewrite a looooooot of our js with some b/c break, and I not really in mood of doing it
Labels |
Added:
bug
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-11-11 19:06:57 |
Closed_By | ⇒ | Fedik |
This is fixed with:
Also see other linked PR in #32663 (comment)
If some specific field is broken, then better open a new issue for that field.
Some time ago I spend some time resurrecting the pr for the modal fields #39351 and asked if this was b/c or not. Didn’t get any answer so I closed it