I have to implement a multifile upload field on one of my OroPlatform entity.
I was thinking about the steps to implement it was quite the same as for the FileType.
So, I have done the following steps:
public function up(Schema $schema, QueryBag $queries)
{
$this->attachmentExtension->addFileRelation(
$schema,
'app_sinister',
'files',
[],
15
);
}
->add('files', MultiFileType::class, ['label' => 'app.sinister.fields.files'])
form_row(form.files)
It seems to work because the attribute appears :
When I have tried to save the form, I have got this error:
I wondered if it was because I have implement a addFileRelation
extension in my migration. I have tried with a addAttachmentAssociation
, it creates these options in back-office but I don't know how to add this attribute to my formType:
In the above migration example, you've added the relation to the single file, but the form type is for multiple files. This leads to an error.
To fix it, you can add a relation to multiple files with the more complex migration:
$this->extendExtension->addManyToOneRelation(
$schema,
$schema->getTable('oro_attachment_file_item'),
'app_sinisters',
$schema->getTable('app_sinister'),
'id',
[
ExtendOptionsManager::MODE_OPTION => ConfigModel::MODE_READONLY,
'extend' => [
'is_extend' => true,
'owner' => ExtendScope::OWNER_CUSTOM,
'without_default' => true,
'on_delete' => 'CASCADE',
],
'datagrid' => ['is_visible' => false],
'form' => ['is_enabled' => false],
'view' => ['is_displayable' => false],
'merge' => ['display' => false]
]
);
$this->extendExtension->addManyToOneInverseRelation(
$schema,
$schema->getTable('oro_attachment_file_item'),
'app_sinisters',
$schema->getTable('app_sinister'),
'files',
['id'],
['id'],
['id'],
[
ExtendOptionsManager::MODE_OPTION => ConfigModel::MODE_READONLY,
'extend' => [
'is_extend' => true,
'owner' => ExtendScope::OWNER_CUSTOM,
'without_default' => true,
'cascade' => ['persist'],
'on_delete' => 'CASCADE',
'orphanRemoval' => true,
'fetch' => ClassMetadataInfo::FETCH_LAZY
],
'datagrid' => ['is_visible' => false],
'form' => ['is_enabled' => false],
'view' => ['is_displayable' => false],
'merge' => ['display' => false]
]
);