How to find out wich helper? "Exception in template helper: TypeError: Cannot read property 'toString' of undefined"

Exception in template helper: TypeError: Cannot read property ‘toString’ of undefined
at Array.forEach ()
at Function..each..forEach (
at Object.contextAdjust (
at Object.afFieldInputContext (
at Function.Template._withTemplateInstanceFunc (

How do you go hunting for these kind of errors?

The error is thrown in the topmost entry of the call stack. In this instance it appears to be aldeed:autoform. I suggest following steps:

  1. download the module as indicated in the stack trace, e.g.
    wget -O autoform.js
  2. load the downloaded file autoform.js in your editor
  3. go to the line 5404, column 26

_id: opt.value.toString(), with column 26 being .toString. This is where the error is thrown. This code appears to be buried in AutoForm.addInputType() of the module aldeed:autoform – does that ring a bell?

Digging around a bit in that function reveals that there must be a context with selectOptions, where each item is supposed to have a label and a value. It looks like one of the values passed is undefined, that causes this error.