title: How to pre-fill Form in SwiftUI
body: <p>i am currently working with <code>Forms</code> in <code>SwiftUI</code>. I am implementing a <strong>EditUser View</strong> and therefore am trying to <strong>pre-fill the Form</strong> with the previous Inputs</p>
  <blockquote>
  <p>I am passing a <strong>User Object</strong> which contains all the relevant Data and using the <strong>initializer</strong> to update all of the input states.</p>
  </blockquote>
  <pre class="lang-swift prettyprint-override"><code>struct EditUserView: View {
      
      let user: User?
      @Binding var showEditUserView: Bool
      
      @State private var gender: User.Gender = .notSet
      @State private var firstName: String = &quot;&quot;
      @State private var lastName: String = &quot;&quot;
      
      init(for user: User?, show: Binding&lt;Bool&gt;) {
          // First, update the Struct Properties with the given Values
          self.user = user
          self._showEditUserView = show
          
          // Second, if a User was given, update all Inputs with the given Values
          if let safeUser = user {
              gender = safeDoctor.gender
              firstName = safeDoctor.firstName
              lastName = safeDoctor.lastName
          }
      }
  
      // Some other Code
  
      Picker(selection: $gender, label: Text(&quot;Gender&quot;)) {
          ForEach(User.Gender.allCases, id: \.self) { gender in
              if gender != .notSet { Text(gender.string).tag(gender) }
          }
      }
      HStack {
          TextField(&quot;FirstName&quot;, text: $firstName)
          Divider()
          TextField(&quot;LastName&quot;, text: $lastName)
      }
  </code></pre>
  <blockquote>
  <p>When creating a new instance of EditUserView while providing a User (NOT nil), the input fields are not getting updated with the provided values.</p>
  </blockquote>
  <p><strong>Can anyone spot a reason for this not to be working?</strong></p>
  <p>Thanks for your help.</p>