Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
im trying to display a list of categries from database in combo box , i write this form of code but it display an error : **my code ** :
`@StateObject var viewModel: MyShopViewModel = MyShopViewModel()
@ObservedObject var catVm: CategoryViewModel
var body: some View {
NavigationView {
VStack {
Form {
Section(header: Text("Product Information")) {
TextField("Product Name", text: .constant(""))
TextField("Product Description", text: .constant(""))
TextField("Product Price", text: .constant(""))
}
Section(header: Text("Product Category")) {
Picker("Category", selection: $catVm.selectedCategory?.id) {
ForEach(catVm.categories, id: \.id) { category in
Text(category.name)
}
}
}
Section(header: Text("Product Image")) {
Text("Image 1")
}
Section(header: Text("Product Publish")) {
Button("Publish your new product!") {
}
}
}
}
}
}
view model :
@Published var categories: [Category] = [Category]()
@Published var selectedCategory: Category? = nil
init() {
Task {
await getCategories()
}
}
func getCategories() async {
let result = await CategoryRepo.getAll()
switch result {
case .success(let data):
categories = data
selectedCategory = data.first
case .failure: print("Cannot fetch categories...")
}
}}````
it display this error Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure from this section Section(header: Text("Product Category")) { Picker("Category", selection: $catVm.selectedCategory?.id) { ForEach(catVm.categories, id: \.id) { category in Text(category.name) } } }