Hi,
First, check if your controller and model are correct and that you correctly
configure the upload folder for file upload (filemount in Typo3 BE and property
$defaultUploadFolder in extension and plugin.tx_myext.settings.imagesFolder =
1:/user_upload/ in TS setup).
In your model :
/**
* Image
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $image = NULL;
with the correct getter and setter.
In your controller :
/**
* Set TypeConverter option for file upload
*/
public function initializeCreateAction() {
$mediaUploadConfiguration = array(
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS
=> $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER =>
$this->settings['imagesFolder'],
);
/** @var PropertyMappingConfiguration $newMyModelConfiguration */
$newMyModelConfiguration =
$this->arguments->getArgument('newModel')->getPropertyMappingConfiguration();
// Define conversion to file reference for image
$newMyModelConfiguration->forProperty('image')
->setTypeConverterOptions(
'COnpany\\MyExt\\Property\\TypeConverter\\UploadedFileReferenceConverter',
$mediaUploadConfiguration
);
}
/**
* action create
*
* @param \Company\MyExt\Domain\Model\MyModel $newModel
* @return void
*/
public function createAction(\Company\MyExt\Domain\Model\MyModel $newModel) {
...
}
Next, check the following points.
In ext_localconf.php :
// For files upload
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter(\Company\MyExt\Property\TypeConverter\UploadedFileReferenceConverter::class);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter(\Company\MyExt\Property\TypeConverter\ObjectStorageConverter::class);
In directory MyExt/Classes/Property/TypeConverter, you should have the two files
from upload_example : ObjectStorageConverter.php &
UploadedFileReferenceConverter.php (don't forget to change the namespace).
In file MyExt/Configuration/TCA/tx_myext_domain_model_mymodel.php
'image' => array(
'exclude' => 1,
'label' => 'Image',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('image',
array(
'appearance' => array(
'elementBrowserType' => 'file',
'elementBrowserAllowed' =>
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
),
'minitems' => 0,
'maxitems' => 1,
// custom configuration for displaying fields in the
overlay/reference table
// to use the imageoverlayPalette instead of the
basicoverlayPalette
'foreign_match_fields' => array(
'fieldname' => 'image',
'tablenames' => 'tx_myext_domain_model_mymodel',
'table_local' => 'sys_file',
),
'foreign_types' => array(
'0' => array(
'showitem' => '
--palette--;;imagePalette,
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette',
),
),
), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),
),
If you add some columns for sys_file_reference, update
Domain/Model/FileReference.php, ext_tables.sql,
/Configuration/TCA/Overrides/sys_file_reference.php
Florian
--
-- Florian Rival --
www.oktopuce.fr
_______________________________________________
TYPO3-english mailing list
TYPO3-english@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english