[TYPO3-mvc] saving file reference with FAL and ext base

Normen Beck n.beck at webraum.de
Thu Jul 4 13:11:00 CEST 2013


Hi,

did you implement getImages and setImages, too?

Regards,
Normen

Am 04.07.13 10:59, schrieb Federico Bernardin:
> 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
>



More information about the TYPO3-project-typo3v4mvc mailing list