@@ -41,13 +41,6 @@ struct ConnectionFormView: View {
4141 authSectionFields. contains { $0. hidesPassword && additionalFieldValues [ $0. id] == " true " }
4242 }
4343
44- private func toggleBinding( for fieldId: String ) -> Binding < Bool > {
45- Binding (
46- get: { additionalFieldValues [ fieldId] == " true " } ,
47- set: { additionalFieldValues [ fieldId] = $0 ? " true " : " false " }
48- )
49- }
50-
5144 @State private var name : String = " "
5245 @State private var host : String = " "
5346 @State private var port : String = " "
@@ -294,9 +287,16 @@ struct ConnectionFormView: View {
294287 )
295288 }
296289 ForEach ( authSectionFields, id: \. id) { field in
297- if field. fieldType == . toggle {
298- Toggle ( field. label, isOn: toggleBinding ( for: field. id) )
299- }
290+ ConnectionFieldRow (
291+ field: field,
292+ value: Binding (
293+ get: {
294+ additionalFieldValues [ field. id]
295+ ?? field. defaultValue ?? " "
296+ } ,
297+ set: { additionalFieldValues [ field. id] = $0 }
298+ )
299+ )
300300 }
301301 if !hidePasswordField {
302302 SecureField (
@@ -931,7 +931,7 @@ struct ConnectionFormView: View {
931931 groupId: selectedGroupId,
932932 safeModeLevel: safeModeLevel,
933933 aiPolicy: aiPolicy,
934- redisDatabase: Int ( additionalFieldValues [ " redisDatabase " ] ?? " " ) ?? 0 ,
934+ redisDatabase: additionalFieldValues [ " redisDatabase " ] . map { Int ( $0 ) ?? 0 } ,
935935 startupCommands: startupCommands. trimmingCharacters ( in: . whitespacesAndNewlines) . isEmpty
936936 ? nil : startupCommands,
937937 additionalFields: finalAdditionalFields. isEmpty ? nil : finalAdditionalFields
@@ -1080,7 +1080,7 @@ struct ConnectionFormView: View {
10801080 color: connectionColor,
10811081 tagId: selectedTagId,
10821082 groupId: selectedGroupId,
1083- redisDatabase: Int ( additionalFieldValues [ " redisDatabase " ] ?? " " ) ?? 0 ,
1083+ redisDatabase: additionalFieldValues [ " redisDatabase " ] . map { Int ( $0 ) ?? 0 } ,
10841084 startupCommands: startupCommands. trimmingCharacters ( in: . whitespacesAndNewlines) . isEmpty
10851085 ? nil : startupCommands,
10861086 additionalFields: finalAdditionalFields. isEmpty ? nil : finalAdditionalFields
0 commit comments