2017-03-02 03:24:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace SilverStripe\Control\Tests\RequestHandlingTest;
|
|
|
|
|
|
|
|
use SilverStripe\Forms\FormRequestHandler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for
|
|
|
|
* @see TestForm
|
|
|
|
*/
|
|
|
|
class TestFormHandler extends FormRequestHandler
|
|
|
|
{
|
|
|
|
private static $url_handlers = array(
|
|
|
|
'fields/$FieldName' => 'handleField',
|
2019-02-23 13:05:18 +01:00
|
|
|
"POST /" => "handleSubmission",
|
|
|
|
"GET /" => "handleGet",
|
2017-03-02 03:24:38 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// These are a different case from those in url_handlers to confirm that it's all case-insensitive
|
|
|
|
private static $allowed_actions = array(
|
|
|
|
'handlesubmission',
|
|
|
|
'handlefield',
|
|
|
|
'handleget',
|
|
|
|
);
|
|
|
|
|
|
|
|
public function handleField($request)
|
|
|
|
{
|
|
|
|
return $this->form->Fields()->dataFieldByName($request->param('FieldName'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handleSubmission($request)
|
|
|
|
{
|
|
|
|
return "Form posted";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handleGet($request)
|
|
|
|
{
|
|
|
|
return "Get request on form";
|
|
|
|
}
|
|
|
|
}
|