简体   繁体   中英

SaveToDatabase in TYPO3 8

How to use form finisher SaveToDataBase in TYPO3 8.7.1? I try to add finisher in YAML, but I have an error:

Argument 1 passed to TYPO3\\CMS\\Form\\Domain\\Finishers\\SaveToDatabaseFinisher::process() must be of the type integer, string given, called in typo3\\sysext\\form\\Classes\\Domain\\Finishers\\SaveToDatabaseFinisher.php on line 207

YAML document:

renderingOptions:
  submitButtonLabel: Submit
type: Form
identifier: form
label: Form
prototypeName: standard
finishers:
  -
    options:
      table: table1
      mode: update
      whereClause:
        uid: '1'
      elements:
        text-1:
          mapOnDatabaseColumn: column1
    identifier: SaveToDatabase
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'previous Page'
      nextButtonLabel: 'next Page'
    type: Page
    identifier: page-1
    label: Page
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: text-1
        label: Text

I had the same TYPO3 exception. Try to write the options as an array, using - . This solved the problem for me.

renderingOptions:
  submitButtonLabel: Submit
type: Form
identifier: form
label: Form
prototypeName: standard
finishers:
  -
    options:
      -
        table: 'table1'
        mode: update
        whereClause:
          uid: '1'
        elements:
          text-1:
            mapOnDatabaseColumn: column1
    identifier: SaveToDatabase
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'previous Page'
      nextButtonLabel: 'next Page'
    type: Page
    identifier: page-1
    label: Page
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: text-1
        label: Text

Example from typo3\\sysext\\form\\Classes\\Domain\\Finishers\\SaveToDatabaseFinisher.php

 * =======
 *
 *  finishers:
 *    -
 *      identifier: SaveToDatabase
 *      options:
 *        table: 'fe_users'
 *        mode: update
 *        whereClause:
 *          uid: 1
 *        databaseColumnMappings:
 *          pid:
 *            value: 1
 *        elements:
 *          text-1:
 *            mapOnDatabaseColumn: 'first_name'
 *          text-2:
 *            mapOnDatabaseColumn: 'last_name'
 *          text-3:
 *            mapOnDatabaseColumn: 'username'
 *          advancedpassword-1:
 *            mapOnDatabaseColumn: 'password'
 *            skipIfValueIsEmpty: true
 *

Maybe I missed something?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM