Routing in custom form field

@lukasbestle thanks for the tips!

I tinkered a bit and it’s works!
Controller is a good think, but it’s not necessary, you can you:

public function routes() {
  return array(
    array(
      'pattern' => 'something/(:any)/(:any)',
      'method'  => 'get',
      'action' => function($var1, $var2)
      {
          // do something
          return response::json(array($var1));
      }
    )
  );
}

The most important thing is to relate the route to the field URL:
http://www.sitename.COM/panel/pages/PAGE_NAME/field/FIELD_NAME_IN_BLUEPRINT/CUSTOM_FORM_FIELD_NAME/something/var1/var2

Thanks!

3 Likes