When creating an editor interface within my plugin, I am using the following snippet to create a set of tabs inside a tab pane:
{% include "_includes/tabs" with {
tabA: { label: 'Tab A'|t, url: '#tabA' },
tabB: { label: 'Tab B'|t, url: '#tabB' },
} %}
<div id="tabA"></div>
<div id="tabB"></div>
Now, when I submit my editor form and there is an error in a form field that's part of tabB, I want to indicate this by highlighting the tab title in red. This is usually done by adding the class 'error' to the tab. So, using Twig, I could determine which tabs have errors right before defining the actual tabs and apply the class 'error' to the relevant tabs. I could also apply the 'error' class using JavaScript upon form initialization.
Just wondering what the recommended way of doing this is or whether there is some built-in code to easily do this?