title: Change style of TextField on focus (without a variable per field)
body: <p>I have a form with nested mini forms (for adding items) so you can add more items (thus adding more fields to the form dynamically). I would like to change the style of the field a user is currently typing on (the focus state).</p>
  <p>I've seen some <a href="https://stackoverflow.com/questions/60379010/how-to-change-swiftui-textfield-style-after-tapping-on-it">solutions using state vars to keep track of each field</a>, but since my fields are being added dynamically, keeping track of an unknown number of variables sounds like more trouble than it should be.</p>
  <pre class="lang-swift prettyprint-override"><code>TextField(&quot;&quot;, text: $viewModel.item.name, onEditingChanged: {
       if $0 {
          //Put something here to change the border or background color directly, maybe reference to the field id or tag?
       }
   })
  .modifier(TextInputStyle(isDisabled : false, isEditing: something)) // Or somehow pass a value here without having to make a state variable
  </code></pre>
  <p><strong>UPDATE</strong>: Thanks to some help, I got closer, but now I'm getting some errors when programmatically disabling the field via a button (toggles <code>isDisabled</code>).</p>
  <p><a href="https://i.stack.imgur.com/TPsox.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TPsox.png" alt="Image of code with errors" /></a></p>
  <p>And in the console, I get this:</p>
  <blockquote>
  <p>=== AttributeGraph: cycle detected through attribute 1864952 ===
  === AttributeGraph: cycle detected through attribute 1864952 ===
  === AttributeGraph: cycle detected through attribute 1864952 ===
  === AttributeGraph: cycle detected through attribute 1866776 ===
  === AttributeGraph: cycle detected through attribute 1865304 ===
  === AttributeGraph: cycle detected through attribute 1865304 ===
  === AttributeGraph: cycle detected through attribute 1862584 ===
  === AttributeGraph: cycle detected through attribute 1847528 ===
  === AttributeGraph: cycle detected through attribute 1847528 ===
  === AttributeGraph: cycle detected through attribute 1865304 ===
  === AttributeGraph: cycle detected through attribute 1878320 ===
  === AttributeGraph: cycle detected through attribute 1878200 ===
  === AttributeGraph: cycle detected through attribute 1878320 ===
  === AttributeGraph: cycle detected through attribute 1878200 ===
  2021-02-08 12:52:20.918323-0600 App [23659:862912] [SwiftUI] Modifying state during view update, this will cause undefined behavior.</p>
  </blockquote>