silverstripe - URL routing not working -


i'm trying url routing working can call functions of controller through ajax. ajax calls formed "ajax/{name of function in controller}/{id pass function}".

i've added following routes.yml:

director:   rules:     'ajax': 'takeactionpage_controller' 

in takeactionpage_controller, have:

private static $url_handlers = array(     'electoratesfrompostcode/$id' => 'electoratesfrompostcode', );  public function electoratesfrompostcode(ss_httprequest $request) {     $id = (int)$request->param('id');      return $this->getelectoratesfrompostcode($id); } 

this not working. when add ?debug_request=1 url of takeactionpage, get:

debug (line 250 of requesthandler.php): testing 'electoratesfrompostcode/$id' '' on takeactionpage_controller debug (line 250 of requesthandler.php): testing '$action//$id/$otherid' '' on takeactionpage_controller debug (line 258 of requesthandler.php): rule '$action//$id/$otherid' matched action 'handleaction' on takeactionpage_controller. latest request params: array ( 'action' => null, 'id' => null, 'otherid' => null, ) debug (line 184 of requesthandler.php): action not set; using default action method name 'index' 

i'm not sure make of debug messages. ideas how working?

try adding $allowed_actions array

public static $allowed_actions = array('electoratesfrompostcode');

see docs: http://doc.silverstripe.org/framework/en/topics/controller#usage


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -