summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-03-22 13:32:08 (GMT)
committerAleksander Machniak <alec@alec.pl>2012-03-22 13:32:08 (GMT)
commitf67428d5163af64c92ad8c01a8ef9ce1e1040a4b (patch)
tree4cf5f918a8bbe20cffd4e4e4930b36e2293f0e1a
parentc4230788ffd11c709097129ddbcfa24b8d94ddef (diff)
downloadkolab-wap-f67428d5163af64c92ad8c01a8ef9ce1e1040a4b.tar.gz
Support multiselect fields with fix for form serialization
-rw-r--r--lib/kolab_client_task.php6
-rw-r--r--lib/kolab_form.php4
-rw-r--r--public_html/js/kolab_admin.js17
3 files changed, 19 insertions, 8 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index dd5a304..25443f2 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -617,6 +617,7 @@ class kolab_client_task
switch ($field['type']) {
case 'select':
+ case 'multiselect':
if (!isset($field['values'])) {
$data['attributes'] = array($field['name']);
$resp = $this->api->post('form_value.select_options', null, $data);
@@ -635,6 +636,11 @@ class kolab_client_task
else {
$result['options'] = array('');
}
+
+ if ($field['type'] == 'multiselect') {
+ $result['multiple'] = true;
+ }
+
break;
case 'list':
diff --git a/lib/kolab_form.php b/lib/kolab_form.php
index a21c758..f5533af 100644
--- a/lib/kolab_form.php
+++ b/lib/kolab_form.php
@@ -284,6 +284,10 @@ class kolab_form
break;
case self::INPUT_SELECT:
+ if (!empty($attribs['multiple']) && empty($attribs['size'])) {
+ $attribs['size'] = 5;
+ }
+
$content = kolab_html::select($attribs, true);
break;
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index ad2f6bc..dabf56c 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -906,16 +906,17 @@ function kolab_admin()
if (v = $('[name="'+extra[i]+'"]', form).val())
json[extra[i]] = v;
- this.form_serialize({id: id, json: json});
-/*
- // convert values of list elements to array type
- $('textarea[data-type="list"]', form).each(function() {
+ // serializeArray() doesn't work properly for multi-select
+ $('select[multiple="multiple"]', form).each(function() {
var name = this.name;
- // maybe already converted by skin engine
- if (!json[name] || !$.isArray(json[name]))
- json[name] = $(this).val().split("\n");
+ json[name] = [];
+ $(':selected', this).each(function() {
+ json[name].push(this.value);
+ });
});
-*/
+
+ this.form_serialize({id: id, json: json});
+
return json;
};