[BUGFIX] Required custom radio field not validated correctly 16/56516/2
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 2 Apr 2018 23:55:03 +0000 (19:55 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 2 Apr 2018 23:56:26 +0000 (01:56 +0200)
Resolves: #84087
Change-Id: I52cb8f02823e0d8a6c0f35c555472536b0dbd771
Reviewed-on: https://review.typo3.org/56516
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
ChangeLog
Classes/Domain/Data.php

index 46f881c..7a03fc9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2018-04-02 Stanislas Rolland  <typo3(arobas)sjbr.ca>
        * Resolves #84076: Honour TS setup delete = 0
        * Resolves #84077: Language label overrides for select fields not respected in forms
+       * Resolves #84087: Required custom radio field not validated correctly
 
 2018-02-09 Stanislas Rolland  <typo3(arobas)sjbr.ca>
        * Resolves #83833: Salutation does not match in registration and response for "Ms" and "Mrs"
index 0330334..33f2834 100644 (file)
@@ -545,7 +545,8 @@ class Data
         * @param string $mode: the current mode (normal or preview)     
         * @return void on return, the parameters failure will contain the list of fields which were not ok
         */
-       public function evalValues(array &$dataArray, array $origArray, $markerObj, $cmdKey, $mode = AbstractView::MODE_NORMAL) {
+       public function evalValues(array &$dataArray, array $origArray, $markerObj, $cmdKey, $mode = AbstractView::MODE_NORMAL)
+       {
                $failureArray = array();
                $failureMsg = array();
                $markerArray = array();
@@ -560,13 +561,21 @@ class Data
                        if ($theField === 'usergroup' && is_object($this->userGroupObj) && is_array($value)) {
                                $value = $this->userGroupObj->restrictToSelectableValues($value, $this->conf, $cmdKey);
                        }
-                       $isMissing = empty($value) && !($theField === 'gender' && $value == '0');
+                       $isMissing = empty($value);
+                       $fieldConfig = $GLOBALS['TCA'][$this->theTable]['columns'][$theField]['config'];
+                       if ($isMissing && $fieldConfig['type'] === 'radio') {
+                               foreach ($fieldConfig['items'] as $k => $item) {
+                                       if ($value == $item[1]) {
+                                               $isMissing = false;
+                                               break;
+                                       }
+                               }
+                       }
                        if ($isMissing) {
                                $failureArray[] = $theField;
                                $this->missing[$theField] = true;
                        }
                }
-
                $pid = $dataArray['pid'];
 
                // Evaluate: This evaluates for more advanced things than "required" does.