diff --git a/gulliver/system/class.form.php b/gulliver/system/class.form.php index 3d3322ad8..f0c9fd1ec 100755 --- a/gulliver/system/class.form.php +++ b/gulliver/system/class.form.php @@ -376,7 +376,30 @@ class Form extends XmlForm switch ($v->type) { case 'radiogroup': $values[$k] = $newValues[$k]; - $values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]]; + + if (isset($v->options[$newValues[$k]])) { + $values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]]; + } else { + $query = G::replaceDataField( $this->fields[$k]->sql, $newValues ); + + //Execute just if a query was set, it should be not empty + if (trim($query) == "") { + continue; //if it is empty string skip it + } + + //We do the query to the external connection and we've got the label + $con = Propel::getConnection(($this->fields[$k]->sqlConnection != "") ? $this->fields[$k]->sqlConnection : "workflow"); + $stmt = $con->prepareStatement($query); + $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM); + + while ($rs->next()) { + list ($rowId, $rowContent) = $rs->getRow(); + if ($newValues[$k] == $rowId) { + $values[$k . "_label"] = $rowContent; + break; + } + } + } break; case 'suggest': $values[$k] = $newValues[$k]; @@ -551,10 +574,10 @@ class Form extends XmlForm case "grid": $values[$k] = $_FILES["form"]["name"][$k]; foreach ($values[$k] as $inp => $ii){ - foreach ($ii as $oo => $ee){ - $x = $v->fields; - $_POST["INPUTS"][$k][$oo] = $x[$oo]->input; - } + foreach ($ii as $oo => $ee){ + $x = $v->fields; + $_POST["INPUTS"][$k][$oo] = $x[$oo]->input; + } } break; }