No Code Attached Yet bug
avatar velisnolis
velisnolis
19 May 2026

Steps to reproduce the issue

  1. In Joomla 6.1.0, create a custom field for articles using the native media document field type.
  2. Configure it for documents so the field stores values like:
{"file":"images/example.pdf","linktext":"Download {filename}"}
  1. Create a repeatable subform custom field for articles.
  2. Add the document field as the subform option.
  3. Edit an article and add/save a document in the repeatable subform.
  4. Reopen the article edit form.

Expected result

The repeatable subform row should render the document/media selector and link text input for the saved document value.

Actual result

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.

System information

Observed on:

  • Joomla 6.1.0
  • PHP 8.4
  • Article custom fields
  • Native document media field inside a repeatable subform custom field

Analysis

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.

Proposed patch

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.

Additional comments

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.

avatar velisnolis velisnolis - open - 19 May 2026
avatar joomla-cms-bot joomla-cms-bot - change - 19 May 2026
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 May 2026
avatar BeginnerJoomlaCom
BeginnerJoomlaCom - comment - 19 May 2026

related report #47799

avatar tecpromotion tecpromotion - change - 19 May 2026
Title
Document media custom field does not render inside repeatable subform
[6.1] Document media custom field does not render inside repeatable subform
avatar tecpromotion tecpromotion - edited - 19 May 2026
avatar tecpromotion tecpromotion - change - 19 May 2026
Labels Added: bug
avatar tecpromotion tecpromotion - labeled - 19 May 2026
avatar tecpromotion
tecpromotion - comment - 19 May 2026

Please test PR #47804

avatar tecpromotion tecpromotion - change - 19 May 2026
Status New Closed
Closed_Date 0000-00-00 00:00:00 2026-05-19 15:51:41
Closed_By tecpromotion
avatar tecpromotion tecpromotion - close - 19 May 2026

Add a Comment

Login with GitHub to post a comment