Skip to content

Instantly share code, notes, and snippets.

@InvisibleKind
Last active May 14, 2019 14:00
Show Gist options
  • Save InvisibleKind/7695771 to your computer and use it in GitHub Desktop.
Save InvisibleKind/7695771 to your computer and use it in GitHub Desktop.
FAL handling in FlexForms
<settings.test>
<TCEforms>
<label>LLL:EXT:my_ext/Resources/Private/Language/locallang_db.xlf:flexform.my_ext.root.test</label>
<config>
<type>inline</type>
<maxitems>1</maxitems>
<foreign_table>sys_file_reference</foreign_table>
<!--<foreign_field>uid_foreign</foreign_field>-->
<foreign_table_field>tablenames</foreign_table_field>
<foreign_label>uid_local</foreign_label>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride type="array">
<config>
<appearance>
<elementBrowserType>file</elementBrowserType>
<elementBrowserAllowed>jpg,png</elementBrowserAllowed>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_match_fields type="array">
<fieldname>image</fieldname>
</foreign_match_fields>
<appearance type="array">
<newRecordLinkAddTitle>1</newRecordLinkAddTitle>
<headerThumbnail>
<field>uid_local</field>
<height>64</height>
<width>64</width>
</headerThumbnail>
</appearance>
</config>
</TCEforms>
</settings.test>
public function indexAction() {
/** @var \TYPO3\CMS\Core\Resource\ResourceFactory $resourceFactory */
$resourceFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
$fileReference = $resourceFactory->getFileReferenceObject($this->settings['test']);
$fileArray = $fileReference->getProperties();
$this->view->assign('image', $fileArray);
}
<f:image src="{image.uid}" treatIdAsReference="1" alt="{image.title}" maxWidth="200" />
@InvisibleKind
Copy link
Author

foreign_match_fields must be different for every plugin's flexform to make distinguish between different plugins

@Christoph-Hofmann
Copy link

not working for TYPO3 7.6.0-dev

if 've got the error:
#1437654409: No $tableName given

InvalidArgumentException thrown in file
/var/www/TYPO3.CMS/typo3/sysext/backend/Classes/Form/FormDataCompiler.php in line 81.

@tbrodard
Copy link

@Christoph-Hofmann Could you make it work for TYPO3 7.6 (the release) ?

@mabo666
Copy link

mabo666 commented Mar 29, 2017

Thank you for this gist. It´s working for 7.6.15 without any error.

@zoranilic
Copy link

For TYPO3 8.7.7 an update for Controller and Fluid template:

(Controller)

/** @var \TYPO3\CMS\Core\Resource\ResourceFactory $resourceFactory */
$resourceFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
$fileReference = $resourceFactory->getFileReferenceObject($this->settings['test']);
$this->view->assign('image', $fileReference);

(Fluid template)

<f:image image="{image}" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment