Buckle up, folks, this is a weird one.
The media field still displays in the subform, and if any value was added to the media field, it remains.
The media field disappears.
Additionally, if you save the article again, the media field will magically reappear (but empty of any value). This happens regardless of what value (if any) you put in the media field. The only time the media field does NOT reappear is if it is the only field in the subform, which is why I included step 2 above.
PHP Version: 8.0.14
Joomla! 4.0.6
It's really fun if you save the article so the subform disappears, go back to the subform configuration, add another media field, and go back to edit the article. The media fields switch on every save and are never shown at the same time.
Labels |
Added:
No Code Attached Yet
|
Thanks Brian. Felt like I was going crazy for a while!
that;s why I quickly posted a confirmation. No idea on the solutions (yet)
I wish we always had such precise instructions on how to reproduce an issue.
Must be related to the subform NOT being repeatable as everything works as expected when it is repeatable
Yup, that's why I included the important note on that step. :)
About to start filming but I found the problem Maybe someone else will write the fix while I am filming
The record saved in #__filed_values when it is not a repeatable subform
{"field3":{"imagefile":"","alt_text":""},"field4":""}
The record saved in #__filed_values when it is a repeatable subform
{"row0":{"field3":{"imagefile":"","alt_text":""},"field4":""}}
Adding the "row0" container to the field value on the non-repeatable subform and it works
I think the answer is in plugins/fields/subform/subform.php
, possibly rows 174-177 because that's where the plugin tries to account for the non repeatable subform. I have no idea how to debug it but I suspect something is not working as expected there when the subform has a media field?
I don't know, I'm wayyyy out of my depth here.
I have figured it out. It's a “simple” matter of data format discrepancy. I will submit a PR for 4.1 very soon.
There you go. It should fairly simple to test.
BTW, neither Brian nor Crystal got the right reason. Since Crystal asked me how did I debug it: The only way to figure out what is going on was to go through a debugger and walk backwards from the subform rendering. After several false starts, I hit Joomla\CMS\Form\Field\SubformField::getInput
where I observed that the $forms[0]
would include the media subfield in one page load and not the next after saving, then back again after saving again. I then noticed that when we call loadSubFormData in that class $this->value
once contained 2 fields (and media field was not shown!) once it contained one field (and the media field WAS shown). How curious! This let me to put a breakpoint in the Joomla\CMS\Form\Field\AccessiblemediaField
to see what the actual bleepit bleeping bleep is going on. I saw the array data coming in and falling through to the second branch of the if-block which provided the much necessary a-ha moment.
yeah I just got back from filming. My main priority was to confirm the bug
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-18 23:00:11 |
Closed_By | ⇒ | richard67 |
confirmed