BUG 6867 problem solved
- there is not more validations for fields that shouldn't have reuiqred validation
This commit is contained in:
@@ -330,9 +330,9 @@ class Form extends XmlForm
|
|||||||
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
|
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
|
||||||
} else {
|
} else {
|
||||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||||
if(trim($query) == '') {
|
if(trim($query) == '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//we do the query to the external connection and we've got the label
|
//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
|
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");//use default connection workflow if connection is not defined. Same as Dynaforms
|
||||||
|
|
||||||
@@ -364,9 +364,9 @@ class Form extends XmlForm
|
|||||||
$values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
|
$values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
|
||||||
} else {
|
} else {
|
||||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||||
if(trim($query) == '') {
|
if(trim($query) == '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//we do the query to the external connection and we've got the label
|
//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");
|
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");
|
||||||
$stmt = $con->prepareStatement($query);
|
$stmt = $con->prepareStatement($query);
|
||||||
@@ -484,42 +484,37 @@ class Form extends XmlForm
|
|||||||
return $aFields;
|
return $aFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that verify the required fields without a correct value
|
* Function that verify the required fields without a correct value
|
||||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values
|
* @param array $dataFields
|
||||||
* @param array $aNoRequiredByJS
|
* @param array $noRequired
|
||||||
* @return array/false
|
* @return array/false
|
||||||
*/
|
*/
|
||||||
function validateRequiredFields($values, $aNoRequiredByJS = array())
|
function validateRequiredFields($dataFields, $noRequired = array())
|
||||||
{
|
{
|
||||||
$rFields = Array();
|
$requiredFields = array();
|
||||||
$missingFields = Array();
|
$notPassedFields = array();
|
||||||
foreach ($this->fields as $o) {
|
$skippedFieldsTypes = array('javascript', 'checkbox', 'yesno', 'submit', 'button', 'title', 'subtitle',
|
||||||
if (is_object($o) && property_exists(get_class($o), 'required')) {
|
'button', 'submit', 'reset', 'hidden', 'link');
|
||||||
if( $o->required == 1) {
|
|
||||||
if (!in_array($o->name, $aNoRequiredByJS)) {
|
foreach ($this->fields as $field) {
|
||||||
array_push($rFields, $o->name);
|
if (is_object($field) && isset($field->required) && $field->required) {
|
||||||
}
|
if (!in_array($field->type, $skippedFieldsTypes)) {
|
||||||
|
array_push($requiredFields, $field->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($rFields as $field){
|
foreach($dataFields as $dataFieldName => $dataField) {
|
||||||
#we verify if the requiered field is in array values,. t
|
//verify if the requiered field is in $requiredFields array
|
||||||
if (array_key_exists($field, $values)) {
|
if (in_array($dataFieldName, $requiredFields) && !in_array($dataFieldName, $noRequired) && trim($dataField) == '') {
|
||||||
if( $values[$field] == "") {
|
$notPassedFields[] = $dataFieldName;
|
||||||
array_push($missingFields, $field);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
array_push($missingFields, $field);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sizeof($missingFields) != 0) {
|
|
||||||
return $missingFields;
|
return count($notPassedFields) > 0 ? $notPassedFields : false;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user