Incompatibility with Inline Form Errors
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3529973. --> Reported by: [huzooka](https://www.drupal.org/user/281301) Related to !6 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>When Inline Form Errors is installed and the file uploaded with the "image_library_widget" does not validate, the user will see the usual "1 error has been found" message with an anchor link to the element, but:</p> <ol> <li>The actual error message is not rendered anywhere on the page.</li> <li>The anchor seems to be broken (it refers an unused HTML ID / name). This issue also exists in the core widgets, but it would be nice to fix it as well in this project.</li> </ol> <p>The reason is that <code>template_preprocess_form_element()</code> is invoked manually in <code>template_preprocess__image_library_widget()</code>, but at the time when the prepreocessed variables reach<br> <code>template_preprocess__image_library_widget()</code>, they are already processed by <code>template_preprocess_form_element()</code>. </p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>See the test I add(ed) to the MR.</p> <ol> <li>Set up this widget at an image field.</li> <li>Limit the allowed extensions to e.g. <code>txt</code></li> <li>Disable JavaScript interpreter so <code>Drupal.file.validateExtension()</code> won't jump in.</li> <li>Limit the allowed extensions to e.g. <code>txt</code></li> <li>With Inline Entity Form installed, visit the form having the image field configured and try to upload a <code>png</code> file.</li> </ol> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Do not call <code>template_preprocess_form_element()</code> manually in <code>template_preprocess__image_library_widget()</code>. Instead, register `form_element__image_library_widget` theme function as a derivative of `form_element`.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3 id="summary-ui-changes">User interface changes</h3> <p>Inline form error message appears.</p> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3>
issue