{"file":"images/example.pdf","linktext":"Download {filename}"}The repeatable subform row should render the document/media selector and link text input for the saved document value.
The repeatable subform table row is rendered, but the nested document field itself is not rendered. Only the repeatable row controls are visible.
The saved value is still present in #__fields_values, for example:
{"row0":{"field5":{"file":"images/example.pdf","linktext":"Download {filename}"}}}The frontend can still use/render the saved value, but the administrator edit form does not show the field, so the editor cannot see or edit the attached document.
Observed on:
Joomla\CMS\Form\Field\AccessiblemediaField::setup() already builds the correct nested field name for non-image media types later in the method:
$mediaTypes = explode(',', $this->types);
$fieldName = (\in_array('images', $mediaTypes)) ? 'imagefile' : 'file';However, before that, the method rejects non-string subform values unless they have image-specific properties:
} elseif (
!\is_object($value)
|| !property_exists($value, 'imagefile')
|| !property_exists($value, 'alt_text')
) {
return false;
}For document fields inside a subform, the value is an object/array with file and linktext, not imagefile and alt_text. This causes setup() to return false, so the nested document field is not rendered.
A minimal fix is to validate the expected value shape according to the configured media type before calling parent::setup():
diff --git a/libraries/src/Form/Field/AccessiblemediaField.php b/libraries/src/Form/Field/AccessiblemediaField.php
index 0000000000..0000000000 100644
--- a/libraries/src/Form/Field/AccessiblemediaField.php
+++ b/libraries/src/Form/Field/AccessiblemediaField.php
@@ -175,13 +175,20 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
}
}
- } elseif (
- !\is_object($value)
- || !property_exists($value, 'imagefile')
- || !property_exists($value, 'alt_text')
- ) {
+ } elseif (!\is_object($value)) {
return false;
+ } else {
+ $mediaTypes = isset($element['types']) ? explode(',', (string) $element['types']) : ['images'];
+ $hasExpectedValue = \in_array('images', $mediaTypes, true)
+ ? property_exists($value, 'imagefile') && property_exists($value, 'alt_text')
+ : property_exists($value, 'file');
+
+ if (!$hasExpectedValue) {
+ return false;
+ }
}
if (!parent::setup($element, $value, $group)) {This preserves the existing validation for image fields while allowing document/audio/video-style media values that use file as the nested value key.
The issue is easiest to see after saving and reopening an article, because the stored subform value is then passed back to AccessiblemediaField::setup() as a non-string value.
| Labels |
Added:
No Code Attached Yet
|
||
| Title |
|
||||||
| Labels |
Added:
bug
|
||
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-05-19 15:51:41 |
| Closed_By | ⇒ | tecpromotion |
related report #47799