{"record":{"id":"afa8259af8441d37","repo":"octobercms/october","slug":"invalid-handler-name-the-correct-handler-name-for-afa825","errorCode":null,"errorMessage":"Invalid handler name. The correct handler name format is: \"onEvent\".","messagePattern":"Invalid handler name\\. The correct handler name format is: \"onEvent\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/system/assets/js/framework.js","lineNumber":327,"sourceCode":"      return out;\n    }\n    getRedirectUrl() {\n      const op = this.getOps(\"redirect\")[0];\n      return op?.url || this.redirect || null;\n    }\n    getReload() {\n      return this.getOps(\"reload\")[0] || null;\n    }\n  };\n\n  // ../../vendor/larajax/larajax/resources/src/request/options.js\n  var Options = class {\n    constructor(handler, options) {\n      if (!handler) {\n        throw new Error(\"The request handler name is not specified.\");\n      }\n      if (!handler.match(/^(?:\\w+\\:{2})?on*/)) {\n        throw new Error('Invalid handler name. The correct handler name format is: \"onEvent\".');\n      }\n      if (typeof FormData === \"undefined\") {\n        throw new Error(\"The browser does not support the FormData interface.\");\n      }\n      this.options = options;\n      this.handler = handler;\n    }\n    static fetch(handler, options) {\n      return new this(handler, options).getRequestOptions();\n    }\n    // Public\n    getRequestOptions() {\n      return {\n        method: \"POST\",\n        url: this.options.url ? this.options.url : window.location.href,\n        headers: this.buildHeaders()\n      };\n    }","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/assets/js/framework.js#L309-L345","documentation":"Thrown by the Options constructor when the handler string does not match /^(?:\\w+\\:{2})?on*/ - the October CMS convention that AJAX handler names start with 'on' (onSave, onDelete), optionally namespaced with a word and double colon prefix (context::onSave). A handler like 'saveForm' or 'MyComponent:onSave' (single colon) fails the check. (The regex is deliberately loose: technically any string starting with 'o' passes, e.g. 'open' - but every well-formed handler starts with 'on'.)","triggerScenarios":"oc.ajax('saveData', {...}) - missing on prefix; oc.request(el, 'component:onSave') - single colon instead of 'context::onSave'; a handler variable with a leading space or different casing such that the on prefix is absent.","commonSituations":"Naming a new PHP handler public function saveData() and forgetting the AJAX framework requires the on prefix; porting jQuery-era code whose action names don't start with 'on'; typos in data-request=\"onSubmirt\"; using single-colon namespacing instead of '::'.","solutions":["Rename the handler so it starts with 'on' (public function onSave() in the component/handler class) and use that name","For namespaced handlers use the word::onHandler form the regex expects","Fix the attribute or argument typo in data-request / the oc.request() call","Test the name against /^(?:\\w+::)?on/ in the console before wiring it up"],"exampleFix":"// PHP: public function saveData() { ... }\n// before\noc.request(el, 'saveData');\n\n// after (rename the PHP method to onSave)\noc.request(el, 'onSave');","handlingStrategy":"validation","validationCode":"const HANDLER_RE = /^(?:\\w+::)?on\\w*$/;\n\nif (HANDLER_RE.test(handler || '')) {\n  oc.request(el, handler);\n} else {\n  console.error(`Handler '${handler}' must start with 'on' (optionally 'context::on...')`);\n}","typeGuard":"const isValidHandlerName = (h) => typeof h === 'string' && /^(?:\\w+::)?on\\w*$/.test(h);","tryCatchPattern":"try { oc.request(el, handler); } catch (e) { if (/Invalid handler name/.test(e.message)) { console.error('Rename the PHP handler to start with on, e.g. onSave'); return; } throw e; }","preventionTips":["Name AJAX handlers on* from the start (onSave, onDelete)","Use the context::onHandler form for namespaced handlers - single colon is rejected","Unit-test handler strings against the regex before wiring markup"],"tags":["ajax","handler","validation","naming","frontend"],"backgroundTag":"invalid-ajax-handler-name","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}