summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-12-15 11:30:03 (GMT)
committerSwift Review <review@swift.im>2013-12-23 13:26:55 (GMT)
commit2cb6df163319cdef371607ad527558e09d707129 (patch)
tree0947c5b5acf7010ff52a37a41a612777d42924c5 /Sluift/ElementConvertors
parent26994474c1ebfe874c2cd62ededf9a82b0496136 (diff)
downloadswift-2cb6df163319cdef371607ad527558e09d707129.zip
swift-2cb6df163319cdef371607ad527558e09d707129.tar.bz2
Sluift: Fix create_submission dropping values from multi fields
Form->Lua conversion no longer relies on the type to decide how to convert values, and blindly converts value arrays. This also fixes issues if Sluift would be used on the receiving side of a form. Change-Id: I92c346795e1c67c74ccf542d16f79fe8010508f7
Diffstat (limited to 'Sluift/ElementConvertors')
-rw-r--r--Sluift/ElementConvertors/FormConvertor.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp
index 9791bfa..26a7d29 100644
--- a/Sluift/ElementConvertors/FormConvertor.cpp
+++ b/Sluift/ElementConvertors/FormConvertor.cpp
@@ -90,17 +90,15 @@ namespace {
if (!field->getDescription().empty()) {
luaField["description"] = Lua::valueRef(field->getDescription());
}
-
- if (field->getType() == FormField::ListMultiType || field->getType() == FormField::JIDMultiType || field->getType() == FormField::TextMultiType) {
- luaField["value"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
- }
- else if (field->getType() == FormField::BooleanType) {
+ if (field->getType() == FormField::BooleanType) {
luaField["value"] = Lua::boolRef(field->getBoolValue());
}
- else if (!field->getValues().empty()) {
+ else if (field->getValues().size() > 1) {
+ luaField["value"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
+ }
+ else if (field->getValues().size() == 1) {
luaField["value"] = Lua::valueRef(field->getValues()[0]);
}
-
if (!field->getOptions().empty()) {
Lua::Array options;
foreach(const FormField::Option& option, field->getOptions()) {