Skip to content

Commit

Permalink
fix multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Jul 3, 2023
1 parent 12921d3 commit b5d8546
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/FilePondField.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,10 @@ public function getPosterHeight()
*/
public function getFilePondConfig()
{
$this->fixName();
$name = $this->getName();
$multiple = $this->getIsMultiUpload();

// Multi uploads need []
if ($multiple && strpos($name, '[]') === false) {
$name .= '[]';
$this->setName($name);
}

$i18nConfig = [
'labelIdle' => _t('FilePondField.labelIdle', 'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>'),
'labelFileProcessing' => _t('FilePondField.labelFileProcessing', 'Uploading'),
Expand Down Expand Up @@ -461,7 +456,6 @@ public function setValue($value, $record = null)
}
$value = ['Files' => $value];
}
// Track existing record data
if ($record) {
$name = $this->name;
if ($record instanceof DataObject && $record->hasMethod($name)) {
Expand Down Expand Up @@ -653,11 +647,27 @@ public function getAttributes()
{
$attrs = parent::getAttributes();

$this->fixName();
$attrs['name'] = $this->getName();

return $attrs;
}

/**
* Make sure the name is correct
*/
protected function fixName()
{
$name = $this->getName();
$multiple = $this->getIsMultiUpload();

// Multi uploads need []
if ($multiple && strpos($name, '[]') === false) {
$name .= '[]';
$this->setName($name);
}
}

public function FieldHolder($properties = array())
{
if (self::config()->enable_requirements) {
Expand Down

0 comments on commit b5d8546

Please sign in to comment.