How to create a file upload field in flexform of a custom extbase extension in TYPO3 10?

落花浮王杯 提交于 2020-05-16 01:33:09

问题


I tried to create a file upload field in flexform of an extbase extension in TYPO3 10. since the internal_type "file" is not supported in TYPO3 10, I tried the below given code.

<settings.bgImage>
    <TCEforms>
        <label>Background Image</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,jpeg,png,svg</elementBrowserAllowed>
                </appearance>
            </config>
            </foreign_selector_fieldTcaOverride>
            <foreign_match_fields type="array">
                <fieldname>image</fieldname>
            </foreign_match_fields>
            <appearance type="array">
                <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                <createNewRelationLinkTitle>Add Image</createNewRelationLinkTitle>
                <headerThumbnail>
                    <field>uid_local</field>
                    <height>64</height>
                    <width>64</width>
                </headerThumbnail>
            </appearance>
        </config>
    </TCEforms>
  </settings.bgImage>

But this is also not working correctly. please help me to fix this. Thank you


回答1:


Here is a currently working complete FlexForm with only a single FAL-Image field. The config has changed again... :-(

<T3DataStructure>
<sheets>
    <sDEF>
        <ROOT>
            <TCEforms>
                <sheetTitle>Example 1</sheetTitle>
            </TCEforms>
            <type>array</type>
            <el>
                <!-- example of a working fal image -->
                <images>
                    <label>FAL-Images</label>
                    <config>
                        <type>inline</type>
                        <foreign_table>sys_file_reference</foreign_table>
                        <foreign_field>uid_foreign</foreign_field>
                        <foreign_sortby>sorting_foreign</foreign_sortby>
                        <foreign_table_field>tablenames</foreign_table_field>
                        <foreign_match_fields>
                            <fieldname>image</fieldname>
                        </foreign_match_fields>
                        <foreign_label>uid_local</foreign_label>
                        <foreign_selector>uid_local</foreign_selector>
                        <overrideChildTca>
                            <columns>
                                <uid_local>
                                    <config>
                                        <appearance>
                                            <elementBrowserType>file</elementBrowserType>
                                            <elementBrowserAllowed></elementBrowserAllowed>
                                        </appearance>
                                    </config>
                                </uid_local>
                            </columns>
                        </overrideChildTca>
                        <filter>
                            <userFunc>TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren</userFunc>
                            <parameters>
                                <allowedFileExtensions></allowedFileExtensions>
                                <disallowedFileExtensions></disallowedFileExtensions>
                            </parameters>
                        </filter>
                        <appearance>
                            <useSortable>1</useSortable>
                            <headerThumbnail>
                                <field>uid_local</field>
                                <width>45</width>
                                <height>45c</height>
                            </headerThumbnail>
                            <enabledControls>
                                <info>1</info>
                                <new>0</new>
                                <dragdrop>1</dragdrop>
                                <sort>0</sort>
                                <hide>1</hide>
                                <delete>1</delete>
                            </enabledControls>
                        </appearance>
                    </config>
                </images>
                <!-- end -->
            </el>
        </ROOT>
    </sDEF>
</sheets>




回答2:


Thanks for the code. I've been looking for a solution here for a while myself.

Unfortunately, the wrong image is displayed in my template. The output in my fluid template is like this:

{f:uri.image(src:'{data.flexform_images}', treatIdAsReference:'1')}

What's wrong?



来源:https://stackoverflow.com/questions/61615558/how-to-create-a-file-upload-field-in-flexform-of-a-custom-extbase-extension-in-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!