about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-13 22:49:04 +0100
committerJames Booth <boothj5@gmail.com>2014-09-13 22:49:04 +0100
commit524a52d0ac7699ac25453f30ae5a49030bb1948a (patch)
tree3e8474ae7f765f532558dc2e24ac0b55c49aafd9
parentb111419693c5f6ac790a9723d75f33dad09a0b64 (diff)
downloadprofani-tty-524a52d0ac7699ac25453f30ae5a49030bb1948a.tar.gz
Added form validation for boolean type
-rw-r--r--src/command/commands.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 19b198f3..673dfd4e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1918,9 +1918,21 @@ cmd_room(gchar **args, struct cmd_help_t help)
                 form_field_type_t field_type = form_get_field_type_by_tag(current->form, tag);
                 switch (field_type) {
                 case FIELD_TEXT_SINGLE:
+                case FIELD_TEXT_PRIVATE:
                     form_set_value_by_tag(current->form, tag, value);
                     ui_current_print_line("%s set to %s", tag, value);
                     break;
+                case FIELD_BOOLEAN:
+                    if (g_strcmp0(value, "on") == 0) {
+                        form_set_value_by_tag(current->form, tag, "1");
+                        ui_current_print_line("%s set to %s", tag, value);
+                    } else if (g_strcmp0(value, "off") == 0) {
+                        form_set_value_by_tag(current->form, tag, "0");
+                        ui_current_print_line("%s set to %s", tag, value);
+                    } else {
+                        ui_current_print_line("Value %s not valid for boolean field: %s", tag, value);
+                    }
+                    break;
                 default:
                     ui_current_print_line("Value %s not valid for field: %s", tag, value);
                     break;