I don't know if you still need help on this or not, but I am the author of the code fragment you are using as a template, and can give you help if you still need it. Sorry I did not notice this thread until today.
I do have a fix for making new spells added be the correct level.
In the game system I am using, there is no such thing as circle zero spells, so I made zero my default value, Anything that was still circle zero was a brand new spell that had not been assigned a circle yet. If your game system allows level zero spells, then you could make your "unassigned" number -1 or any other otherwise invalid number.
You will notice in the css, that any spell that is circle zero is always displayed, no matter which tab is checked.
So if "Level 3" is checked, then it displays only those spells that are level 0 or level 3. Once again, if you are using level 0 as a valid level, then you can change it so that level -1 and 3 are displayed.
In your code you took this line out, probably because level zero spells were valid in your system, and you wanted to filter to display them. Once again, what you need to do is have it always display the "brand new unassigned" spells.
/* Decide which specific repitems to display. */
input.sheet-spells-tab0:checked~.sheet-filtered-box, /* Always display all spells of circle zero. */
.sheet-spells-tab0:checked~.sheet-section-sp-list>fieldset.repeating_spell+.repcontainer>.repitem .sheet-filtered-box, /* When tab0 is checked, display everything no matter what which of the inner boxes are checked. */
.sheet-spells-tab1:checked~.sheet-section-sp-list>fieldset.repeating_spell+.repcontainer>.repitem input.sheet-spells-tab1:checked~.sheet-filtered-box,
So what happens is that if you are displaying only level 3 spells, and you add a new spell, it will have a level of zero (or -1 in your version), and the new blank spell will be displayed along with level 3 spells.
I have sheetworker section with the following line.
on("change:repeating_spell:sp_name", fn(repSpellName ) );
Part of the code inside of that is
var t = getInt( values, "tab-spells");
if(( circle == 0) && (t != 0)) {
circle = t;
vals[ strS1 ] = circle;
}
Which is to say, that whenever the spell name changes, check to see if the circle has been set to a valid rank. If it is still at the "new spell" circle, then check to see if we are only displaying spells of a curtain level. If so, make the new spell to be that level.
Thus, if you are only displaying level 3 spells, and you change a spell name of a spell that is listed as being unassigned, change the spells rank to be 3.
This fragment is obviously not complete, my code does several other things as well, but it should get you started if you already know about sheetworkers. Your top post sais you did not want to use them, so ... Anyway, this step is optional, but if you want it I can give you the whole routine and you can cut out all the parts you don't need.
This last step is optional, as the user can manually assign the spell to any rank that he wants, but it does save a stop, if he is only displaying one level of spells, he presses add, a blank spell appears, he sets the name, and the level of the spell automaticaly changes to that level.
Please let me know if there is anything more I help you with.