@@ -930,10 +930,10 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
930930 if ($ itemtype === User::class && $ field === "pdffont " && $ fromdb ) {
931931 return ;
932932 }
933+ $ injectionClass = self ::getInjectionClassInstance ($ itemtype );
933934 // TODO awfull hack, text ftom CSV set more than once, so check if "another" value
934935 if (isset ($ this ->values [$ itemtype ][$ field ]) && $ this ->values [$ itemtype ][$ field ] != $ value ) {
935936 // Data set twice (probably CSV + Additional info)
936- $ injectionClass = self ::getInjectionClassInstance ($ itemtype );
937937 $ option = self ::findSearchOption ($ injectionClass ->getOptions ($ itemtype ), $ field );
938938
939939 if (isset ($ option ['displaytype ' ]) && $ option ['displaytype ' ] == 'multiline_text ' ) {
@@ -955,7 +955,7 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
955955 }
956956 } else { // First value
957957 if (empty ($ value )) {
958- if (isForeignKeyField ($ field ) || (strpos ($ field , 'is_ ' ) !== false )) {
958+ if (isForeignKeyField ($ field ) || (strpos ($ field , 'is_ ' ) !== false ) || ( method_exists ( $ injectionClass , ' isNullable ' ) && ! $ injectionClass -> isNullable ( $ field )) ) {
959959 // If the field is an id, we set it to 0
960960 $ this ->values [$ itemtype ][$ field ] = self ::DROPDOWN_EMPTY_VALUE ;
961961 } else {
@@ -1596,7 +1596,6 @@ public function processAddOrUpdate()
15961596
15971597 foreach ($ this ->values as $ itemtype => $ data ) {
15981598 //Do not process primary_type
1599-
16001599 if ($ itemtype != get_class ($ item )) {
16011600 $ injectionClass = self ::getInjectionClassInstance ($ itemtype );
16021601 $ item = new $ itemtype ();
0 commit comments