Project

General

Profile

Actions

Bug #94050

open

Do not reload form on change if mandatory fields are not filled in

Added by Daniel Kempf over 3 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2021-05-04
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In a backend form there are several fields configured by TCA. Some of them are mandatory. Also there are some IRRE fields for adding relations to other tables. In case of adding a new IRRE relation it does kind of deactivate the mandatory validation although some mandatory fields are not filled in.

It would be better not to reload form on changes as long as not all mandatory fields are filled in.

As additional note, the tca of the inline related record has field properties: 'onChange' => 'reload' and 'eval' => 'required'. Example:

'starttype' => [
    'onChange' => 'reload',
    'label' => 'LLL:EXT:example/Resources/Private/Language/locallang_db.xlf:tx_example.starttype',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'items' => [
            ['LLL:EXT:example/Resources/Private/Language/locallang_db.xlf:tx_example.starttype.please_select',-1],
            ['LLL:EXT:example/Resources/Private/Language/locallang_db.xlf:tx_example.starttype.date',1],
            ['LLL:EXT:example/Resources/Private/Language/locallang_db.xlf:tx_example.starttype.on_request',2],
            ['LLL:EXT:example/Resources/Private/Language/locallang_db.xlf:tx_example.starttype.continuously',3],
        ],
        'eval' => 'required',
    ],
],


Files

tcademo.zip (6.31 KB) tcademo.zip Gernot Ploiner, 2022-11-27 07:24

Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Feature #60908: Provide Evaluation of TCA select fieldsNew2014-08-12

Actions
Related to TYPO3 Core - Bug #94090: Unexpected form validation with fal imageClosed2021-05-07

Actions
Actions #1

Updated by Daniel Kempf over 3 years ago

  • Description updated (diff)
Actions #2

Updated by Daniel Kempf over 3 years ago

  • Description updated (diff)
Actions #3

Updated by Daniel Kempf over 3 years ago

  • Description updated (diff)
Actions #4

Updated by Daniel Kempf over 3 years ago

  • Description updated (diff)
Actions #5

Updated by Timo Pfeffer almost 3 years ago

Daniel Kempf wrote:

In a backend form there are several fields configured by TCA. Some of them are mandatory. Also there are some IRRE fields for adding relations to other tables. In case of adding a new IRRE relation it does kind of deactivate the mandatory validation although some mandatory fields are not filled in.

It would be better not to reload form on changes as long as not all mandatory fields are filled in.

As additional note, the tca of the inline related record has field properties: 'onChange' => 'reload' and 'eval' => 'required'. Example:
[...]

upvote! Because this handling can cause broken Slug entries. For example: You want to generate a Slug based on the title field of an object. When the onChange handling is now fired, then it ignores the mandatory fields and generates a Slug called "default-#####". After that process is done, then it is not possible that the user can update this slug.

This behauviour is also existing in TYPO3 v9

Actions #6

Updated by Gernot Ploiner about 2 years ago

I have the same problem:

...

'employee' => [
    'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:employee',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'foreign_table' => 'fe_users',
        'items' => [['LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.actions.all.empty', '']],
        'default' => '',
        'eval' => 'required',
        'minitems' => 0,
        'maxitems' => 1,
    ],
],
...

I have the 'onchange' setting at an other field. If I change it without filling the employee select, i get an error:
2: SQL error: 'Incorrect integer value: '' for column `db`.`tx_xxx_domain_model_xxx`.`employee` at row 1' (tx_xxx_domain_model_xxx:NEW637873aa9e433573083688)

Reloading after filling out all required fields can be a solution. But I would suggest to disable validations and don't save to the DB on reloading: Simply reload the form and refill all fields as before. Validate only on saving.

I know, the setting 'eval' at selectSingle is not documented, but it works.
See: https://forge.typo3.org/issues/60908

Tested with TYPO3 10 and PHP 7.4

Actions #7

Updated by Sybille Peters about 2 years ago

  • Related to Feature #60908: Provide Evaluation of TCA select fields added
Actions #8

Updated by Gernot Ploiner almost 2 years ago

I attached a small extension for TYPO3 11.5 (there is the same behavior as in 10.4) to easyly reproduce the two related problems:

Installation:
Install the extension: ddev composer require webprofil/tcademo:@dev
In the TYPO3 Backend:
  • create a regular page (e.g. uid=1)
  • create a folder in the pagetree (e.g. uid=2)
  • create a fegroup at the folder
  • create some feusers at the folder
  • create a 'Dummy' record at your page or folder

Now you can see the problems:

  1. Before you save, change the select "Type" to "Type 1". Then reload (click "yes"). This errormessage apperars, because "Employee" is not filled out:
    "2: SQL error: 'Incorrect integer value: '' for column `db`.`tx_tcademo_domain_model_dummy`.`employee` at row 1' (tx_tcademo_domain_model_dummy:NEW63830ddb4a18d611387331)"
  2. The "Employee" select is displayed as I expect. But as I know, the TCA-property 'eval' => 'required' is not allowed (and not documented) at TCA select / selectSingle. Without eval, it is not possible to make a selectSingle required with a "pleasechoose" option.
Actions #9

Updated by Georg Ringer 5 months ago

  • Related to Bug #94090: Unexpected form validation with fal image added
Actions

Also available in: Atom PDF