[TYPO3-mvc] saving file reference with FAL and ext base
Federico Bernardin
typo3list at bernardin.it
Thu Jul 4 15:43:56 CEST 2013
Hi,
I have just seen an issue about this problem:
http://forge.typo3.org/issues/47694
Cheers
Federico
Il giorno 04/lug/2013, alle ore 10:59, Federico Bernardin <typo3list at bernardin.it> ha scritto:
> Hi,
> I have this situation:
> A user can save some images from frontend and I want to use FAL to save file and link this file with a specified Extbase model object myobject.
> Myobject is a model with images property:
>
> /**
> * images
> *
> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
> */
> protected $images;
>
> /**
> * Constructor.
> */
> public function __construct() {
> $this->initStorageObjects();
> }
>
> /**
> * Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties.
> *
> * @return void
> */
> protected function initStorageObjects() {
> $this->images = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
> }
>
> /**
> * Adds a Comment.
> *
> * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image Add a image.
> *
> * @return void
> */
> public function addImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image) {
> $this->images->attach($image);
> }
>
> /**
> * Removes a Comment.
> *
> * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove The Image to be removed.
> *
> * @return void
> */
> public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove) {
> $this->images->detach($imageToRemove);
> }
>
>
> My TCA has an images field as below:
>
> 'images' => array(
> 'exclude' => 0,
> 'label' => 'images',
> 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('images')
> ),
>
> When I save file on storage all works ok, but when I link image (saved) to myobject doesn't work. After myobject is persisted in sys_file_reference there's one row (i linked only one image) but uid_local, table_local, fieldname are empty.
>
> If I use normal back-end to create the object (myobject) all works fine, images are linked correctly, so I suppose TCA works fine.
>
> So I decided to create my Model for FileReference (extends original extbase FileReference) and I added uidLocal, tableLocal and FieldName properties (setter and getter methods too), I added typoscript to map properties with database fields, and uid_local and table_local (setted by controller) are written into db row. But fieldname is not defined into TCA of sys_file_reference and so it cannot be persisted.
>
> The images field into myobject table is not setted with number of images linked with sys_file_reference too.
>
> I don't succeed to find a solution, can someone help me?
>
> Thanks
> Federico
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
More information about the TYPO3-project-typo3v4mvc
mailing list