This commit is contained in:
Laurent Destailleur
2023-01-19 01:16:39 +01:00
parent 49473e5934
commit e28fce6318
27 changed files with 56 additions and 132 deletions

View File

@@ -7858,30 +7858,34 @@ abstract class CommonObject
/**
* Return validation test result for a field
*
* @param array $val Array of properties of field to show
* @param array $fields Array of properties of field to show
* @param string $fieldKey Key of attribute
* @param string $fieldValue value of attribute
* @return bool return false if fail true on success, see $this->error for error message
*/
public function validateField($val, $fieldKey, $fieldValue)
public function validateField($fields, $fieldKey, $fieldValue)
{
global $langs;
if (!class_exists('Validate')) { require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; }
if (!class_exists('Validate')) {
require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php';
}
$this->clearFieldError($fieldKey);
if (!isset($val[$fieldKey])) {
if (!isset($fields[$fieldKey])) {
$this->setFieldError($fieldKey, $langs->trans('FieldNotFoundInObject'));
return false;
}
$val = $fields[$fieldKey];
$param = array();
$param['options'] = array();
$type = $val[$fieldKey]['type'];
$type = $val['type'];
$required = false;
if (isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1) {
if (isset($val['notnull']) && $val['notnull'] === 1) {
// 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
$required = true;
}
@@ -7892,6 +7896,7 @@ abstract class CommonObject
//
// PREPARE Elements
//
$reg = array();
// Convert var to be able to share same code than showOutputField of extrafields
if (preg_match('/varchar\((\d+)\)/', $type, $reg)) {
@@ -7905,7 +7910,7 @@ abstract class CommonObject
$type = 'select';
}
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
if (!empty($val['type']) && preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
$type = 'link';
}