Massimo - just installed this version, it's been a little while since upgrading. Using this version, I find that, in a form, the form.vars object contains less info than it used to. It seems to only contain fields that are readable/writable. Looking back a few versions, I see this behavior since 20251109. form.vars in 20251012 and prior also contained fields that were not readable. This in itself is not a problem for me, but what is causing me problems is the following:
For list:integer fields, I don't like the standard multi-select object where you have to press Ctrl and click multiple items - instead I build a select object with a scrolling list of checkboxes, which I find gives a much better user experience. To do it, I need to add fields to the form, which I do in the template. For example:
<!-- skip diet widget and build a scrollable list of checkboxes instead: -->
[[vals = form.vars['diets'] or [] ]]
<ul class="scroller">
[[for (k,v) in db.diets:]]
<li><label for=[[=v]]>
<input type=checkbox name="diets_[[=k]]" id="[[=k]]" [[="checked" if k in vals else ""]]> [[=v]]
</label></li>
[[pass]]
</ul>
In the controller, when the form is submitted, I then need to look through form.vars for fields named "diets_1", "diets_2" etc and rebuild the 'diets' value based on which ones are checked:
recipe.diets = process_diets(form) # update our custom form item for diets
def process_diets(form):
dietList = []
for name, val in form.vars.items():
if name.startswith('diets_') and val == 'on': # checkbox selected gives 'on'
dietList.append(makeInt(name.split('-')[-1]))
return dietList
The controller no longer sees these extra fields in form.vars. So I need my custom fields in the form, and I need the controller to recognize them! Is there another way that I can accomplish this?