summaryrefslogtreecommitdiff
path: root/lib/kolab_client_task.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-03-16 08:38:21 (GMT)
committerAleksander Machniak <alec@alec.pl>2012-03-16 08:38:21 (GMT)
commitfcfcc465d4c7a80b4d5b9c765f778c434e492000 (patch)
tree8ade75f20587e22bf9fd45885f1aa7665842f4cd /lib/kolab_client_task.php
parentd09b405ca61e5cb73253300884669156d0e7685b (diff)
downloadkolab-wap-fcfcc465d4c7a80b4d5b9c765f778c434e492000.tar.gz
Fix handling of disabled (auto-generated) fields (#635)
Diffstat (limited to 'lib/kolab_client_task.php')
-rw-r--r--lib/kolab_client_task.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index cc9dcea..4e1c90c 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -629,12 +629,13 @@ class kolab_client_task
/**
* HTML Form elements preparation.
*
- * @param string $name Object name (user, group, etc.)
- * @param array $data Object data
+ * @param string $name Object name (user, group, etc.)
+ * @param array $data Object data
+ * @param array $extra_fields Extra field names
*
* @return array Fields list, Object types list, Current type ID
*/
- protected function form_prepare($name, &$data)
+ protected function form_prepare($name, &$data, $extra_fields = array())
{
$types = (array) $this->{$name . '_types'}();
$form_id = $attribs['id'];
@@ -646,6 +647,8 @@ class kolab_client_task
$fields = array();
$auto_attribs = array();
+ $extra_fields = array_flip($extra_fields);
+
// Selected account type
if (!empty($data[$name . '_type_id'])) {
$type = $data[$name . '_type_id'];
@@ -662,6 +665,7 @@ class kolab_client_task
// Mark automatically generated fields as read-only, etc.
foreach ($auto_fields as $idx => $field) {
if (!is_array($field)) {
+ unset($auto_fields[$idx]);
continue;
}
// merge with field definition from
@@ -678,6 +682,8 @@ class kolab_client_task
$fields[$idx]['readonly'] = true;
$fields[$idx]['disabled'] = true;
+ $extra_fields[$idx] = true;
+
// build auto_attribs and event_fields lists
$is_data = 0;
if (!empty($field['data'])) {
@@ -693,6 +699,7 @@ class kolab_client_task
}
else {
$auto_attribs[] = $idx;
+ unset($auto_fields[$idx]);
}
}
@@ -702,6 +709,9 @@ class kolab_client_task
$field['name'] = $idx;
$fields[$idx] = $this->form_element_type($field);
}
+ else {
+ unset($extra_fields[$idx]);
+ }
// $fields[$idx]['required'] = true;
$fields[$idx]['readonly'] = false;
$fields[$idx]['disabled'] = false;
@@ -714,7 +724,10 @@ class kolab_client_task
}
}
+ // Register list of auto-generated fields
$this->output->set_env('auto_fields', $auto_fields);
+ // Register list of disabled fields
+ $this->output->set_env('extra_fields', array_keys($extra_fields));
// (Re-|Pre-)populate auto_form_fields
if ($add_mode) {