Project

General

Profile

Actions

Bug #39673

closed

FlexForm value was saved, regardless if &$set was set or not in checkValue-process

Added by Stefan Froemken over 11 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2012-08-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hello TYPO3-Core-Team,

I have found following in your TCE-Documentation regarding own validators:

&$set : Boolean defining if the value is written to the database or not. Must be passed by reference and changed if needed.

I have used this validator in a FlexForm:

<settings.prependPdfs>
  <TCEforms>
    <exclude>1</exclude>
    <label>Prepend following PDFs</label>
    <config>
      <type>text</type>
      <cols>50</cols>
      <rows>5</rows>
      <eval>Tx_KeEinkaufsplaner_Validator_Eval</eval>
    </config>
  </TCEforms>
</settings.prependPdfs>

Now we come to the part with $set:

public function evaluateFieldValue($value, $is_in, &$set) {
  if (empty($value)) return $value;
  if (preg_match('/[^a-zA-Z0-9_-]/', $value)) {
    //t3lib_utility_Debug::debug('unallowed letters found', 'ERROR');
    $set = FALSE;
  } else {
    //t3lib_utility_Debug::debug('OK', 'OK');
    $set = TRUE;
  }
  return $value;
}

I'm sure: If I am NOT working within a FlexForm it will work without any problems!

In method: checkValue_flex_procInData_travDS you only override an existing value instead of creating a new value. That's why ALL FlexForm values are ALWAYS saved, regardless if I break saving process with $set = FALSE or TRUE:

// Adding the value:
if (isset($res['value'])) {
  $dataValues[$key][$vKey] = $res['value'];
}

While in method fillInFieldArray you fill a nearly empty $fieldArray:

// Evaluating the value
$res = $this->checkValue($table, $field, $fieldValue, $id, $status, $realPid, $tscPID);
if (isset($res['value'])) {
  $fieldArray[$field] = $res['value'];
}

If I break saving process here, the requested value will not be added to $fieldArray and will not be saved in database.


Files

39673.diff (559 Bytes) 39673.diff Patch: 39673.diff Stefan Froemken, 2012-08-10 09:49
Actions

Also available in: Atom PDF