/** * @return Form */ public function createComponentPopupMultiTestForm() { $form = new Form(); $form->addText('description', 'Description:'); $form->addMultiSelectFileChoicer('multipleFileChoicer', $this->mediaManager, 'mediastorage/test/multi', 'Choice file:', true); $form->addSubmit('submit', 'Send'); $manager = $this->mediaManager; $form->onSuccess[] = function (Form $form, $values) use($manager) { /** @var MultiSelectFileChoicer $choicer */ $choicer = $form['multipleFileChoicer']; $manager->saveUsages($choicer->getNamespace(), $choicer->getUsedIds(), $choicer->getRemovedIds()); $manager->setPrimary('mediastorage/test/multi', $choicer->getPrimaryId()); }; return $form; }