FIX Protection to avoid an extrafield to be mandatory if computed
This commit is contained in:
parent
9dc1c6f8f4
commit
d77eca294f
1 changed files with 11 additions and 0 deletions
|
|
@ -148,6 +148,7 @@ class ExtraFields
|
|||
|
||||
$result = 0;
|
||||
|
||||
// Clean properties
|
||||
if ($type == 'separate') {
|
||||
$unique = 0;
|
||||
$required = 0;
|
||||
|
|
@ -158,6 +159,10 @@ class ExtraFields
|
|||
if ($elementtype == 'contact') {
|
||||
$elementtype = 'socpeople';
|
||||
}
|
||||
// If property has a computed formula, it must not be a required field
|
||||
if (!empty($computed)) {
|
||||
$required = 0;
|
||||
}
|
||||
|
||||
// Create field into database except for separator type which is not stored in database
|
||||
if ($type != 'separate') {
|
||||
|
|
@ -568,6 +573,7 @@ class ExtraFields
|
|||
}
|
||||
|
||||
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
|
||||
// Clean parameters
|
||||
if ($type == 'boolean') {
|
||||
$typedb = 'int';
|
||||
$lengthdb = '1';
|
||||
|
|
@ -604,6 +610,11 @@ class ExtraFields
|
|||
}
|
||||
$field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default'=>$default);
|
||||
|
||||
// If property has a computed formula, it must not be a required field
|
||||
if (!empty($computed)) {
|
||||
$required = 0;
|
||||
}
|
||||
|
||||
if (is_object($hookmanager)) {
|
||||
$hookmanager->initHooks(array('extrafieldsdao'));
|
||||
$parameters = array('field_desc'=>&$field_desc, 'table'=>$table, 'attr_name'=>$attrname, 'label'=>$label, 'type'=>$type, 'length'=>$length, 'unique'=>$unique, 'required'=>$required, 'pos'=>$pos, 'param'=>$param, 'alwayseditable'=>$alwayseditable, 'perms'=>$perms, 'list'=>$list, 'help'=>$help, 'default'=>$default, 'computed'=>$computed, 'entity'=>$entity, 'langfile'=>$langfile, 'enabled'=>$enabled, 'totalizable'=>$totalizable, 'printable'=>$printable);
|
||||
|
|
|
|||
Loading…
Reference in a new issue