BUG 6867 problem solved
- there is not more validations for fields that shouldn't have reuiqred validation
This commit is contained in:
@@ -488,38 +488,33 @@ class Form extends XmlForm
|
|||||||
* 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