Issue Bug Under Review Quiet

#85772EXT:form SaveToDatabaseFinisher cannot handle multi value fields

Vasyl Mosiychuk 08/07/18, 13:42 updated 10/07/26, 14:37

Description

[..]
        properties:
          options:
            1: 'Label 1'
            2: 'Label 2'
        type: MultiSelect
        identifier: categories
        label: 'Multi select'
        defaultValue:
          - '2'
[...]
          uid_foreign:
            value: '{SaveToDatabase.insertedUids.0}'
[...]

If I save only one value and not empty, work it. If a value more one it not work

I mean this is about `type: MultiSelect` and `type: ImageUpload`.
How to work with `SaveToDatabase` if I to pass for saving in the DB not one value and two value or three and more

Reviews 1

History 2143

Show 18 earlier messages
  1. Susanne Moog changed subject I can not saving in the DB values if I pass for saving in the DB not one value and two value or three and more? EXT:form SaveToDatabaseFinisher cannot handle multi value fields <span data-processor="relativetime" data-value="2018-09-02T17:38:15+00:00" > 09/02/18, 17:38 </span>

  2. Susanne Moog commented <span data-processor="relativetime" data-value="2019-04-25T21:46:49+00:00" > 04/25/19, 21:46 </span>

    The SaveToDatabase finisher was originally meant to provide a starting point for custom implementations and is therefor currently not capable of rendering all possible fields and combinations. In stable releases it should be used for very simple forms or as code tutorial on how to develop own finishers.

    For future versions we need to define a concept of how and what we want to ship with the core.

  3. Vasyl Mosiychuk commented <span data-processor="relativetime" data-value="2019-04-28T20:17:45+00:00" > 04/28/19, 20:17 </span>

    Susanne Moog wrote:
    > The SaveToDatabase finisher was originally meant to provide a starting point for custom implementations and is therefor currently not capable of rendering all possible fields and combinations. In stable releases it should be used for very simple forms or as code tutorial on how to develop own finishers.
    >
    > For future versions we need to define a concept of how and what we want to ship with the core.

    In to manual not said nothing about that the `ext:from` … should be used for very simple forms or as code tutorial on how to develop own finishers, as for a non-technical editor, so and as an experienced integrator.

    I think the `ext:form` is should provide possibility to save all data in the database which sent from the form.

    In this case TYPO3 and the `ext:from` will be available for all users, and really will be simple and easy…

  4. Björn Jacob commented and changed target version <span data-processor="relativetime" data-value="2019-04-28T21:10:39+00:00" > 04/28/19, 21:10 </span>

    If you want to store the form data in your database, try this extension: https://github.com/pagemachine/typo3-formlog.

  5. Vasyl Mosiychuk commented <span data-processor="relativetime" data-value="2019-04-29T22:04:50+00:00" > 04/29/19, 22:04 </span>

    Bjoern Jacob wrote:
    > If you want to store the form data in your database, try this extension: https://github.com/pagemachine/typo3-formlog.

    No, this is not that what need…

    I need save data in the table of database for example extension news or other extension where is in the record has more one category and more one images.

  6. Susanne Moog commented <span data-processor="relativetime" data-value="2019-04-29T22:55:23+00:00" > 04/29/19, 22:55 </span>

    The problem is, we will not be able to support arbitrary use cases. One use case could be to have categories as csv – kind of a log entry -, the next wants the categories created and saved as 1:n relation, next is m:m relation and so on. We have no secure way of figuring out what kind of form people are building and guessing will make the situation worse. Trying to support any kind of datastructures will be extremely complicated, quite impossible to get right and complex – whereas creating an own finisher for your specific case should be a lot more straightforward, as you – and only you – know exactly what you are building and what the logic should be for the relations.

    The only reliable configuration source we have for tables with relations at the moment would be TCA, which would essentially mean, rebuilding form engine (backend forms) for the frontend – that however would not be a task for the form framework, but rather a separate package.

  7. Vasyl Mosiychuk commented <span data-processor="relativetime" data-value="2019-05-24T11:39:50+00:00" > 05/24/19, 11:39 </span>

    Susanne Moog wrote:
    > The problem is, we will not be able to support arbitrary use cases. One use case could be to have categories as csv – kind of a log entry -, the next wants the categories created and saved as 1:n relation, next is m:m relation and so on. We have no secure way of figuring out what kind of form people are building and guessing will make the situation worse. Trying to support any kind of datastructures will be extremely complicated, quite impossible to get right and complex – whereas creating an own finisher for your specific case should be a lot more straightforward, as you – and only you – know exactly what you are building and what the logic should be for the relations.
    >
    > The only reliable configuration source we have for tables with relations at the moment would be TCA, which would essentially mean, rebuilding form engine (backend forms) for the frontend – that however would not be a task for the form framework, but rather a separate package.

    …and there are not so many cases, mainly it is “categories” and “tags” and “sys_file_reference”.

    at least core “sys_category” and “sys_file_reference” would be well

    I think, that need describing in the documentation about those cases. Can you describe in documentation create own finisher for this case as an example?

  8. Julian Stock commented <span data-processor="relativetime" data-value="2020-08-13T22:41:02+00:00" > 08/13/20, 22:41 </span>

    Vasyl Mosiychuk wrote:
    > […]
    > I think, that need describing in the documentation about those cases. Can you describe in documentation create own finisher for this case as an example?

    Do you still need help? I managed to get some sys_category in the ext:form frontend via a custom formElementsDefinition (in yaml & php, mainly following this: https://daniel-siepmann.de/posts/2017/how-to-create-typo3-form-select-element-with-options-selected-from-database.html), set it to MultiSelect and used the default (but extended) SaveToDatabaseFinisher plus a following SaveToDatabaseFinisher which gets the ‘{SaveToDatabase.insertedUids.0}’ value.

    This is the logic of my second SaveToDatabaseFinisher:

            // ...
    
            protected function saveToDatabase(array $databaseData, string $table, int $iterationCount) {
                // ...
    
                $categories = explode(",", $databaseData["categories"]);
                $sorting = 0;
                foreach ($categories as $category) {
                    $categoryData = [
                        "uid_local" => $databaseData["guide_id"],
                        "uid_foreign" => $category,
                        "sorting" => $sorting
                    ];
    
                    parent::saveToDatabase($categoryData, $table, $iterationCount);
    
                    $sorting++;
                }
            }
    
            // ...

    Have a great day!

  1. Daniel Janek commented and changed PHP Version 7.2 8.2 <span data-processor="relativetime" data-value="2026-02-26T15:47:41+00:00" > 02/26/26, 15:47 </span>

    Problem still exists in v13 (thanks for change TYPO3 Version Mathias Brodalla)

  2. Josua Vogel commented <span data-processor="relativetime" data-value="2026-05-11T09:41:22+00:00" > 05/11/26, 09:41 </span>

    Hi @software ,
    Could you test or check my latest patch?