BUG 5934 "save labels for checkgroups.... solving problems"

This commit is contained in:
Erik Amaru Ortiz
2011-06-02 19:52:57 -04:00
parent 236585d03b
commit ab6abc2f0b
2 changed files with 29 additions and 19 deletions

View File

@@ -312,30 +312,40 @@ class Form extends XmlForm
case 'checkgroup':
case 'listbox':
$values[$k] = '';
foreach ($newValues[$k] as $i => $value) {
$values[$k] .= ($i != 0 ? '|': '') . $value;
if (isset($v->options[$value])){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
} else {
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
//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");//use default connection workflow if connection is not defined. Same as Dynaforms
$stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
if ( is_array($newValues[$k]) ) {
$values[$k] = '';
foreach ($newValues[$k] as $i => $value) {
//if $value is empty continue with the next loop, because this is a not selected/checked item
if (trim($value) == '') {
continue;
}
while ($rs->next()) {
list($rowId, $rowContent) = $rs->getRow();
$values[$k] .= ($i != 0 ? '|': '') . $value;
if (isset($v->options[$value])){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
} else {
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
//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");//use default connection workflow if connection is not defined. Same as Dynaforms
$stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
list($rowId, $rowContent) = $rs->getRow();
if ($value == $rowId){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $rowContent;
break;
if ($value == $rowId){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $rowContent;
break;
}
}
}
}
$newValues[$k] = $values["{$k}_label"];
} else {
$values[$k] = $newValues[$k];
$values["{$k}_label"] = $newValues["{$k}_label"];
}
$newValues[$k] = $values["{$k}_label"];
break;
case 'dropdown':

View File

@@ -4177,7 +4177,7 @@ class XmlForm
if (isset ( $xmlNode [$k]->attributes ['required'] )) {
// the fields or xml nodes with a required attribute are put in an array that is passed to the view file
if ($xmlNode [$k]->attributes ['required'] == 1)
if ($xmlNode [$k]->attributes ['required'] == 1 && $xmlNode [$k]->attributes['mode'] != 'view' && $this->mode == 'edit')
$this->requiredFields [] = array ('name' => $field->name, 'type' => $xmlNode [$k]->attributes ['type'], 'label' => trim ( $field->label ) );
}