FAL saving image in backend module does not set the uid_local - typo3

I have a backend module that does some data transfer from an old 'profile' database to TYPO3.
For the images, I first renamed them and placed them in a storage.
The records of the profiles also have been copied and are stored in the DB.
I then get the file information of each file that is in the storage for a profile
$file = $storage->getFile($filetoget['filename']);
and gives me just what i need.
I then create a new file reference object:
$profilemedia = $this->objectManager->get('TYPO3\Regprofiler\Domain\Model\FileReference');
I can add all properties to this object that i need.
I also set:
$profilemedia->setUidLocal($fileProps['uid']);
when I then add the image to my profile and update my profile repository, all file refrences get stored as expected, EXCEPT the uid_local, this stays 0
what is annoying, because this way I don't get a reference to the sys_file and therefore: no image.
So why don't I get the uid_local stored ?
my TCA for the image
'image' => array(
'exclude' => 1,
'label' => 'image',
'l10n_mode' => 'mergeIfNotBlank',
'config' => array(
'type' => 'inline',
'foreign_sortby' => 'sorting',
'foreign_table' => 'tx_regprofiler_domain_model_profiler',
'foreign_field' => 'parent',
'size' => 5,
'minitems' => 0,
'maxitems' => 99,
'appearance' => array(
'collapseAll' => 1,
'expandSingle' => 1,
'levelLinksPosition' => 'bottom',
'useSortable' => 1,
'showPossibleLocalizationRecords' => 1,
'showRemovedLocalizationRecords' => 1,
'showAllLocalizationLink' => 1,
'showSynchronizationLink' => 1,
'enabledControls' => array(
'info' => FALSE,
)
)
)
),

Please make sure, before creating a module to generate your data, that you can create the database-records using the TYPO3-Backend. Simply add a record and check if you can add an Image there. If it appears, you have an error in your module, else you have an error in your TCA.
It is also recommended using
$TCA['tx_yourext_domain_model_yourmodel']['columns']['image']['config'] =
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('yourImageFieldHere',
array(
'maxitems' => 1,
'appearance' => array(
'createNewRelationLinkTitle' => 'LLL:EXT:nwb_page_tools/Resources/Private/Language/locallang_customlabels.xlf:add_image'
)
),
'jpg,png'
);
in your TCA definition. This is a core method wich can be reviewed here

Related

TYPO3: Issue with File upload and File reference

I have "Book" model with a "pdf" and "image" property. Both property are files that can be uploaded by the user.
I followed Helhum's example for the image upload and it works fine.
I tried to do the same for the "pdf" field but it doesn't work. The file is being uploaded, the file ID is also saved in the database but the file reference is missing.
Here is a dump of the "Book" object after the upload:
pdf => NULL
image => Vendor\MyExt\Domain\Model\FileReference
In the "setTypeConverterConfigurationForImageUpload" function I added this line the pdf property:
$newExampleConfiguration->forProperty('pdf')
->setTypeConverterOptions(
'Vendor\\MyExt\\Property\\TypeConverter\\UploadedFileReferenceConverter',
$uploadConfiguration
);
I am probably missing something but I don't what.
EDIT:
I found the issue thanks to Heinz and Ghanshyam. It was a mistake in the TCA.
Here is how my working TCA looks like:
'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_book',
'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']),
),

TYPO3 v4.6 about IRRE (sorting)

We must update the field data sorting sorting.
I set $TCA['tx_table2']['ctrl']['sortby'] = 'sorting';
And i set:
$TCA['tx_table1']['columns']['uid_records'] = array(
............
'config' => array(
'type' => 'inline',
'languageMode' => 'inherit',
'foreign_table' => 'tx_table2',
'foreign_sortby' => 'sorting',
'size' => 1,
'minitems' => 0,
'maxitems' => 100,
)
);
But when moving the recording position, the data field sorting is not updated.
Values are recorded only when creating a new record.
What could be the problem?

How to modify the TCA ImageManipulation configuration of a FAL reference?

In TYPO3 7.4 I have the following TCA configuration for uploading a single image with the new ImageManipulation (crop tool) enabled:
'single_image_field' => array(
'exclude' => 1,
'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:sometable.single_image_field',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'single_image_field',
array(
'maxitems' => 1,
'appearance' => array(
'collapseAll' => 1,
'expandSingle' => 1,
),
'foreign_types' => array(
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => array(
'showitem' => '--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette'
),
)
),
'jpg,jpeg,png'
),
),
Now I like to have my custom aspect ratio's configured. This seems possible with the TCA configuration of column type: ImageManipulation (see: https://wiki.typo3.org/TYPO3.CMS/Releases/7.2/Feature#Impact_9).
But how can I apply this in the above configuration?
The default crop aspect ratio's for sys_file_reference can be overwritten as follows:
$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config']['ratios'] = array(
'1.7777777777777777' => '16:9',
'1.3333333333333333' => '4:3',
'1' => '1:1',
'NaN' => 'Free',
);

How to make file_reference in extbase extension in TYPO3 6.1 work?

I have set up a small extension with the extension builder containing a few fields, one of which is the internal_type: 'file_reference'.
'dokument' => array(
'exclude' => 0,
'label' => 'LLL:EXT:publikationen/Resources/Private/Language/locallang_db.xlf:tx_publikationen_domain_model_publikation.dokument',
'config' => array(
'type' => 'group',
'internal_type' => 'file_reference',
//'uploadfolder' => 'uploads/tx_publikationen',
'allowed' => '*',
'disallowed' => 'php',
'size' => 5,
),
),
The field appears in the backend, but the Element browser is unable to show any files to select:
If I remove the "bparams" parameter from the URL shown above, it is able to see the files that are there.
How can this be brought to work?
FAL fields require complicated configuration. To make that easier, there is a function returning the TCA config for such a field.
Its usage for a field that allows only one file looks like this:
'dokument' => array(
'label' => 'LLL:EXT:publikationen/Resources/Private/Language/locallang_db.xlf:tx_publikationen_domain_model_publikation.dokument',
'exclude' => 0,
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'dokument',
array(
'maxitems' => 1,
'minitems' => 1,
'appearance' => array(
'enabledControls' => array(
'dragdrop' => FALSE,
'localize' => FALSE,
),
),
)
),
),
A look into the source code of that function makes me not want to do that manually.

Typo3, TCA forms view depending on the chosen option

I have made in backend a TCA form, what will change depending of the value in select field "type":
This select field contains basically the options:
rte text
url
picture
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
In my case the content is always saved in database in field "content" and the selected type is saved in field "type".
My problem is that I have not found a way to change the "content" form field / configuration, depending on the selected type.
For example when I choose "rte text" it should use for the content field this kind of configuration (rich text editor):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
and when I choose "picture" it should use for the content field this kind of configuration (file uploader):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
Is there a way to change that configuration depending of the value in the selectbox. I have tried to put two contents in an array but haven't got it working on that way.
Unfortunately you cannot change the properties of a single field via type.
You can however influence what's being displayed. So you can configure two independent fields and switch the display:
ext_tables.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => array(
//...
'type'=>'type',
//...
),
);
TCA.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
'types' => array(
0 => array('showitem' => 'content_rte'),
1 => array('showitem' => 'content_image'),
),
'columns' => array(
'content_rte' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
'content_upload' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
),
// ...
);
(Note: I've removed system fields like hidden, sys_language_uid etc. for simplicity's sake)