diff --git a/application/models/Survey.php b/application/models/Survey.php index 08bb09175eb..67c23365e49 100755 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -640,14 +640,22 @@ public function getTokenAttributes() $ls->save(); $attdescriptiondata = $fields; } + // Without token table : all extra attribute are only saved on $this->attributedescriptions + $allKnowAttributes = $attdescriptiondata; + // Without token table : all attribute $this->attributedescriptions AND real attribute. @see issue #13924 + if($this->getHasTokensTable()){ + $allKnowAttributes = array_intersect_key(array_merge($attdescriptiondata,Token::model($this->sid)->getAttributes()),Token::model($this->sid)->getAttributes()); + // We remove deleted attribute even if deleted manually in DB + } $aCompleteData = array(); - foreach ($attdescriptiondata as $sKey=>$aValues) { - if (!is_array($aValues)) { - $aValues = array(); - } - if (preg_match("/^attribute_[0-9]{1,}$/", $sKey)) { + foreach ($allKnowAttributes as $sKey=>$aValues) { + if (preg_match("/^attribute_[0-9]{1,}$/", $sKey)) { // Select only extra attributes here + if (!is_array($aValues)) { + $aValues = array(); + } + // merge default with attributedescriptions $aCompleteData[$sKey] = array_merge(array( - 'description' => '', + 'description' => $sKey, 'mandatory' => 'N', 'show_register' => 'N', 'cpdbmap' =>''