I am getting the error in the title on the following form. Cannot figure out why. Please help! I do not have any custom style for forms or anything. Also getting an info bubble on the line as well that says "'init(_:)' declared here (SwiftUI.Form)"
Form { Section(header: Text("Employee Name")) { TextField("First Name", text: $user.user?.firstName ?? "") TextField("Last Name", text: $user.user?.lastName) }
Section(header: Text("Employee and Store Info")) {
TextField("Store Number", text: Int($user.user?.storeNumber))
.keyboardType(.numberPad)
TextField("Team Member Number", text: Int($user.user?.teamMemberNumber))
}
}
what code do you have a problem with? The unformatted code, or the code in the code block?
The unformatted code works for me, but I had to replace
$user.user?.firstName ?? ""
with $firstName, where I declared a
@State private var firstName = "Joe",
and similarly for lastName.
The formatted code shouldn't compile, because Int() returns an Int, while ``TextField's text: parameter should be a Binding<String>
Try simplifying your code to something you can post as a complete sample. That alone may lead you to a solution. If it doesn't, post the complete sample here and indicate clearly what is not working (you said "in the title on the following form", but there is no "title" field). Also mention what platform (macOS, iOS etc) you are targeting, and what Xcode version you are using.