Feature #85378

EXT:form option for saving uploaded file as sys_file_reference

Added by Lidia Demin 6 months ago. Updated 4 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2018-06-25
Due date:
% Done:

0%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

In #85216 we discovered two problems:
  • The description how to save an uploaded file as sys_file_reference is missing.
  • If the file field isn't mandatory and therefore empty the insert query for the sys_file_reference table throws an exception.

For the second problem the suggestion was to use a custom SaveToDatabase finisher.

I think this whole thing should be easier, especially because there are only two fields that need to be configured for the sys_file_reference table. The configuration could look something like this:

finishers:
  -
    identifier: SaveToDatabase
    options:
      table: 'tx_myext_domain_model_mymodel'
      mode:  'insert'
      elements:
        logo:
          mapOnDatabaseColumn: 'logo'
          saveAsFileReference: true
          skipIfValueIsEmpty: true

The SaveToDatabaseFinisher needs to be extended to look for those options and:
  1. Automatically performing an insert query on the sys_file_reference table with tablenames = <options.table> and fieldname = <options.elements.elementName>
  2. Skip both the setting of the field in <options.table> and the complete insert query for sys_file_reference

Related issues

Related to TYPO3 Core - Bug #85772: EXT:form SaveToDatabaseFinisher cannot handle multi value fields New 2018-08-07
Copied from TYPO3 Core - Task #85216: EXT:form SaveToDatabase Finisher saves files as sys_file, not as sys_file_reference Closed 2018-06-11

History

#1 Updated by Lidia Demin 6 months ago

If you like this idea, I could try the implementation.

#2 Updated by Lidia Demin 6 months ago

  • Copied from Task #85216: EXT:form SaveToDatabase Finisher saves files as sys_file, not as sys_file_reference added

#3 Updated by Vasyl Mosiychuk 4 months ago

Lidia Demin wrote:

If you like this idea, I could try the implementation.

Hello! Is there a any the positive solution of this?

#4 Updated by Lidia Demin 4 months ago

  • Description updated (diff)

I haven't started yet, because there was no feedback to this proposal. But seems, it just got a +1 from you ;)

#5 Updated by Ralf Zimmermann 4 months ago

I'll take a look in the next days.

#6 Updated by Vasyl Mosiychuk 4 months ago

  • Related to Bug #85772: EXT:form SaveToDatabaseFinisher cannot handle multi value fields added

#7 Updated by Vasyl Mosiychuk 4 months ago

Lidia Demin wrote:

I haven't started yet, because there was no feedback to this proposal. But seems, it just got a +1 from you ;)

Thanks!

Yes, you are right. I want to add to the DB via ext:form not only one value and two or more values. I mean this is about `type: MultiSelect` and `type: ImageUpload`. This types which can have not one value and two or more values or can to be empty.

For example, I have:

      -
        properties:
          systemCategoryUid: ''
          validationErrorMessages:
            -
              code: '1475002976'
              message: 'Min 1'
            -
              code: '1475002994'
              message: 'Max 3'
          fluidAdditionalAttributes:
            required: required
        defaultValue: ''
        type: MultiSelectSysCategory
        identifier: categories
        label: 'Categories'
        validators:
          -
            identifier: NotEmpty
          -
            options:
              minimum: '1'
              maximum: '3'
            identifier: Count
      -
        properties:
          saveToFileMount: '1:/user_upload/'
          allowedMimeTypes:
            - image/jpeg
            - image/png
            - image/bmp
          imageLinkMaxWidth: '500'
          imageMaxWidth: '500'
          imageMaxHeight: '500'
        type: ImageUpload
        identifier: attachment
        label: Attachment

and finisher:

 -
    options:
      -
        table: tx_foo_domain_model_foo
        mode: insert
        databaseColumnMappings:
          pid:
            value: '0'
          datetime:
            value: '{__currentTimestamp}'
          tstamp:
            value: '{__currentTimestamp}'
          crdate:
            value: '{__currentTimestamp}'
        elements:
          categories:
            mapOnDatabaseColumn: categories
          title:
            mapOnDatabaseColumn: title
          bodytext:
            mapOnDatabaseColumn: bodytext
          attachment:
            mapOnDatabaseColumn: fal_media
      -
        table: sys_category_record_mm
        mode: insert
        elements:
          categories:
            mapOnDatabaseColumn: uid_local
        databaseColumnMappings:
          tablenames:
            value: tx_foo_domain_model_foo
          fieldname:
            value: categories
          uid_foreign:
            value: '{SaveToDatabase.insertedUids.0}'
      -
        table: sys_file_reference
        mode: insert
        elements:
          attachment:
            mapOnDatabaseColumn: uid_local
        databaseColumnMappings:
          table_local:
            value: sys_file
          tablenames:
            value: tx_foo_domain_model_foo
          fieldname:
            value: fal_media
          tstamp:
            value: '{__currentTimestamp}'
          crdate:
            value: '{__currentTimestamp}'
          uid_foreign:
            value: '{SaveToDatabase.insertedUids.0}'
    identifier: SaveToDatabase

The identifier: categories can to pass to the DB few values but the finisher give possibility save only one value

The identifier: attachment can to pass few values too

at the moment can save only one value

I hope that you you are understood my bad English ... sorry for my English is my bad

I hope that not only I, it who want this possibility.

Also available in: Atom PDF