The ai_json_schema form element does not adhere to form states visible
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3579425. --> Reported by: [marcus_johansson](https://www.drupal.org/user/385947) Related to !1326 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Short Description: </strong>[One-line issue summary for stakeholders]<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>If you usue the <code>ai_json_schema</code> form element and use a <a href="https://www.drupal.org/docs/drupal-apis/form-api/conditional-form-fields">form state</a> to hide it, its still visible. Probably because it creates a mockup field of the original field.</p> <h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4> <p>Please provide information like AI modules enabled, which AI provider, browser, etc.</p> <p>1. Add a checkbox form element called <code>structured_output_shown</code><br> 2. Add a <code>ai_json_schema</code> element.<br> 3. Add the following state information on it:</p> <pre>'#states' =&gt; [<br>&nbsp; 'visible' =&gt; [<br>&nbsp;&nbsp;&nbsp; ':input[name="structured_output_shown"]' =&gt; ['checked' =&gt; TRUE],<br>&nbsp; ],<br>],</pre><p> 4. Notice that if you check or uncheck the checkbox makes no difference if the form element is shown.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Make sure that the <code>ai_json_schema</code> element works with hidden state.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3> <h3 id="summary-ai-usage">AI usage (if applicable)</h3> <p>[ ] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p> <p>[ ] AI Assisted Code<br> This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p> <p>[ ] AI Generated Code<br> This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p> <p>[ ] Vibe Coded<br> This code was generated by an AI and has only been functionally tested.</p>
issue