Skip to content

Commit

Permalink
FIX Apply multiupload auto-detection for upload fields (#1108)
Browse files Browse the repository at this point in the history
UploadField checks hasone components based on the field name to see if
it can be a multiUpload field or not. We need to trigger that before
changing the name of the field.
  • Loading branch information
GuySartorelli authored Oct 11, 2023
1 parent c3132ff commit 6e3180c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Forms/EditFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\Forms;

use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Forms\DefaultFormFactory;
Expand Down Expand Up @@ -66,6 +67,10 @@ protected function namespaceFields(FieldList $fields, array $context)
$elementID = $context['Record']->ID;

foreach ($fields->dataFields() as $field) {
if ($field instanceof UploadField) {
// Apply audo-detection of multi-upload before changing the name.
$field->setIsMultiUpload($field->getIsMultiUpload());
}
$namespacedName = sprintf(self::FIELD_NAMESPACE_TEMPLATE ?? '', $elementID, $field->getName());
$field->setName($namespacedName);
}
Expand Down

0 comments on commit 6e3180c

Please sign in to comment.