From 524a52d0ac7699ac25453f30ae5a49030bb1948a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Sep 2014 22:49:04 +0100 Subject: Added form validation for boolean type --- src/command/commands.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/command') 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; -- cgit 1.4.1-2-gfad0