TYPO3 change PID in TCA - typo3

I am trying to change the pid in my extension. I added the pid field to my tca, it also shows the current pid, but as soon as I change it and save it, the old pid comes back :(
'pid' => [
'exclude' => true,
'label' => 'change pid',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
],
],
what am I doing wrong?

You can use this to set pid like this.
$querySettings = $this->yourRepository->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds([$pid]);
$this->yourRepository->setDefaultQuerySettings($querySettings);
I am not sure about the requirement, If I am wrong here, please excuse me.

Related

TYPO3 Prefill text field in my own extension

I need to save the IP address of a user who fills out my form.
I have tried to do it like this:
'userip' => [
'exclude' => true,
'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myextension_domain_model_myextension.userip',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => '12345'.$_SERVER["REMOTE_ADDR"]
]
],
But that doesn't work. What would be the right way?
$_SERVER["REMOTE_ADDR"] is not available in TCA cause this is BE related stuff.
Use the setter from the model, setUserip($_SERVER["REMOTE_ADDR"]), in your createAction() or initializeCreateAction() to save the value in DB.

Update reference index in fields with rendertype inputLink

Links to files or images in fields which use the renderType inputLink (e.g header_link in the normal content elements) do not update the reference index when the content element is saved.
My TCA:
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => '',
],
],
],
'softref' => 'typolink'
(the same as in header_link in the content elements)
Is there a possibility to force the correct handling of the reference index? The editors can't see which files are linked and which not, so they can delete the files in file module without error message.
Thanks
this bug was fixed with TYPO3 9.7.12:
https://review.typo3.org/c/Packages/TYPO3.CMS/+/62205

rendertype inputlink for huge files without copying the file

I need a tca field with a link to huge files (100-900 MB). I used this TCA:
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'fieldControl' => [
'linkPopup' => [
'options' => [
'blindLinkOptions' => 'mail,page,spec,url,folder',
'blindLinkFields' => 'class,params,target,title',
],
],
],
]
It works but when I save the data TYPO3 seems to copy the file and I get the error message that the limit of 50 MB is exceeded. But I need only a simple link to the file.
In version 7 it worked with this code:
'config' => array (
'type' => 'input',
'size' => '100',
'max' => '255',
'eval' => 'trim',
'wizards' => array(
'_PADDING' => 2,
'link' => array(
'type' => 'popup',
'title' => 'LLL:EXT:cms/locallang_ttc.xml:header_link_formlabel',
'icon' => 'link_popup.gif',
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard',
'act' => 'file'
)
),
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
)
),
)
but it doesn't work anymore in TYPO3 8.
How can i fix the problem?
Correction:
I am sorry but I was wrong. The whole question is wrong: The above configuration works as expected, it does not copy the file, it only links to the file. I made another error which leads to a misunderstanding of my real problem.
Sorry for the noise ...
In order to close the topic I will mark the answer as correct. In some way it was because it gave me a good hint.
Take a look to FAL. Here the files are only referenced to the orgin file.
'image' => array(
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.images',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('image', array(
'appearance' => array(
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
),
// custom configuration for displaying fields in the overlay/reference table
// to use the imageoverlayPalette instead of the basicoverlayPalette
'foreign_types' => array(
...
)
), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])
),

TYPO3 foreign_table_where not works properly

I have TYPO3 version 7.6.18.
'images' => [
'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:images',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_fefiles_domain_model_photo',
'foreign_field' => 'album',
'foreign_table_where' => 'AND tx_fefiles_domain_model_photo.allow = 1',
'maxitems' => '5000'
],
],
This is configuration in TCA for someone field.
in table tx_fefiles_domain_model_photo I have 4 rows which id = album,
but allow = 1 only two. But I get all four rows. My condition tx_fefiles_domain_model_photo.allow = 1 does't works. I tried different variants, cleared cache. Really I need your help, I must make it works, help me please (
Try:
'foreign_match_fields' => [
'allow' => 1
]
instead of foreign_table_where.
For examples look into documentation: https://docs.typo3.org/typo3cms/TCAReference/

Backend TCA: possible to make a field nullable?

I need a backend field where users can enter a time (ie "23:13:46", hours, minutes, seconds). But it should also be possible to not enter a time at all (which should of course be different from 00:00:00). Is it possible to make a field nullable?
What I have so far is this:
$GLOBALS['TCA']['tx_something_domain_model_delivery'] = array(
'columns' => array(
'deadline' => array(
'exclude' => 1,
'label' => 'Deadline',
'config' => array(
'dbType' => 'time',
'type' => 'input',
),
),
...
),
);
But if I enter nothing in the Deadline field, it stores "00:00:00" to the database. The database looks like this:
CREATE TABLE IF NOT EXISTS `tx_something_domain_model_delivery` (
`uid` int(11) NOT NULL,
`pid` int(11) NOT NULL DEFAULT '0',
`deadline` time DEFAULT NULL,
...
);
so deadline is nullable, but I don't know how to achieve this.
BTW: I'm a newbie at typo3, so if you think the way I create the field is retarded or there is a much better way, I'd be thankful for any suggestions.
First: You are creating the field exactly in the intended way :-)
Second: You need to use the eval property in the configuration of the field. Add the setting null to it. Your config should then look like this:
$GLOBALS['TCA']['tx_something_domain_model_delivery'] = array(
'columns' => array(
'deadline' => array(
'exclude' => 1,
'label' => 'Deadline',
'config' => array(
'dbType' => 'time',
'type' => 'input',
'eval' => 'null',
),
),
...
),
);
There are more settings for the eval setting that might be of interest to you.