src/Component/Frontend/StructureModal/StructureModal.php
protected function createComponentFormFileProperty() : Multiplier
    {
        $structureValueFiles = [];

        // TODO: Vyřešit přes SQL i když to nějak moc nezpomaluje :-D

        /** @var RecipeVariable $recipeVariable */
        foreach ($this->getFileVariables()->toKeyIndex('Slug') as $recipeVariable)
        {
            foreach ($recipeVariable->getStructureValues() as $structureValue)
            {
                foreach ($structureValue->getStructureValueFiles() as $structureValueFile)
                {
                    $structureValueFiles[$structureValueFile->getId()] = $structureValueFile;
                }
            }
        }

        return new Multiplier(function ($structureValueFileId) use ($structureValueFiles)
        {
            /** @var StructureValueFile $structureValueFile */
            $structureValueFile = $structureValueFiles[$structureValueFileId];

            $form = new Form;

            $form->addText('title')
                ->setRequired('Titulek je povinný.')
                ->addRule(Form::MAX_LENGTH, 'Maximální délka titulku je %d znaků.', 128);

            $form->addText('uploadedAt')
                ->setRequired('Datum nahrání je povinný.')
                ->addRule(Form::PATTERN, "Datum vytvoření musí být ve formátu: 24.8.2018 08:59:01.", self::REGEX_DATETIME);

            $form->addHidden('structureValueFileId', $structureValueFileId);

            $form->addSubmit('save');


            if (!$this->getStructure())
            {
                foreach ($form->getComponents() as $component)
                {
                    $component->setDisabled(TRUE);
                }
            }

            $form->setDefaults([
                'title' => $structureValueFile->getTitle(),
                'uploadedAt' => $structureValueFile->getUploadedAt()->format(self::FORMAT_DATETIME),
            ]);

            $form->onValidate[] = function (Form $form) { $this->validate($form); };
            $form->onSuccess[] = function (Form $form) { $this->successFileProperty($form); };

            if (!$this->presenter->user->isAllowed(StructureAuthorizator::RES_STRUCTURE_MODAL))
            {
                $this->setDisabledForm($form, TRUE);
            }

            return $form;
        });
    }
protected function createComponentFormFileProperty() : Multiplier
    {
        $structureValueFiles = [];

        // TODO: Vyřešit přes SQL i když to nějak moc nezpomaluje :-D

        /** @var RecipeVariable $recipeVariable */
        foreach ($this->getFileVariables()->toKeyIndex('Slug') as $recipeVariable)
        {
            foreach ($recipeVariable->getStructureValues() as $structureValue)
            {
                foreach ($structureValue->getStructureValueFiles() as $structureValueFile)
                {
                    $structureValueFiles[$structureValueFile->getId()] = $structureValueFile;
                }
            }
        }

        return new Multiplier(function ($structureValueFileId) use ($structureValueFiles)
        {
            /** @var StructureValueFile $structureValueFile */
            $structureValueFile = $structureValueFiles[$structureValueFileId];

            $form = new Form;

            $form->addText('title')
                ->setRequired('Titulek je povinný.')
                ->addRule(Form::MAX_LENGTH, 'Maximální délka titulku je %d znaků.', 128);

            $form->addText('uploadedAt')
                ->setRequired('Datum nahrání je povinný.')
                ->addRule(Form::PATTERN, "Datum vytvoření musí být ve formátu: 24.8.2018 08:59:01.", self::REGEX_DATETIME);

            $form->addHidden('structureValueFileId', $structureValueFileId);

            $form->addSubmit('save');


            if (!$this->getStructure())
            {
                foreach ($form->getComponents() as $component)
                {
                    $component->setDisabled(TRUE);
                }
            }

            $form->setDefaults([
                'title' => $structureValueFile->getTitle(),
                'uploadedAt' => $structureValueFile->getUploadedAt()->format(self::FORMAT_DATETIME),
            ]);

            $form->onValidate[] = function (Form $form) { $this->validate($form); };
            $form->onSuccess[] = function (Form $form) { $this->successFileProperty($form); };

            if (!$this->presenter->user->isAllowed(StructureAuthorizator::RES_STRUCTURE_MODAL))
            {
                $this->setDisabledForm($form, TRUE);
            }

            return $form;
        });
    }
File property forms
@return Multiplier
@throws \Propel\Runtime\Exception\PropelException