diff options
-rw-r--r-- | lib/kolab_client_task.php | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php index da0acf5..b784856 100644 --- a/lib/kolab_client_task.php +++ b/lib/kolab_client_task.php @@ -1070,25 +1070,11 @@ class kolab_client_task $extra_fields[$idx] = true; - // build auto_attribs and event_fields lists - $is_data = 0; + // build event_fields list if (!empty($field['data'])) { - foreach ($field['data'] as $fd) { - $event_fields[$fd][] = $idx; - if (isset($data[$fd])) { - $is_data++; - } - } - if (count($field['data']) == $is_data) { - $auto_attribs[] = $idx; - } - } - else { - //console("\$field['data'] is empty for \$auto_fields[\$idx] (idx: $idx)"); - $auto_attribs[] = $idx; - // Unset the $auto_field array key to prevent the form field from - // becoming disabled/readonly - unset($auto_fields[$idx]); + foreach ($field['data'] as $fd) { + $event_fields[$fd][] = $idx; + } } } @@ -1112,6 +1098,33 @@ class kolab_client_task } } + // Re-parse auto_fields again, to get attributes for auto-generation + // Need to do this after form_fields have been initialized (#2980) + foreach ($auto_fields as $idx => $field) { + // build auto_attribs and event_fields lists + if (!empty($field['data'])) { + $is_data = 0; + foreach ($field['data'] as $fd) { + if (!isset($data[$fd]) && isset($fields[$fd]['value'])) { + $data[$fd] = $fields[$fd]['value']; + } + if (isset($data[$fd])) { + $is_data++; + } + } + + if (count($field['data']) == $is_data) { + $auto_attribs[] = $idx; + } + } + else { + $auto_attribs[] = $idx; + // Unset the $auto_fields array key to prevent the form field from + // becoming disabled/readonly + unset($auto_fields[$idx]); + } + } + // Get the rights on the entry and attribute level $data['effective_rights'] = $this->effective_rights($name, $data['id']); $attribute_rights = (array) $data['effective_rights']['attribute']; |