2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Control\Tests\RequestHandlingTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\Forms\Form;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form for the test
|
|
|
|
*/
|
|
|
|
class TestForm extends Form implements TestOnly
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $url_handlers = array(
|
|
|
|
'fields/$FieldName' => 'handleField',
|
|
|
|
"POST " => "handleSubmission",
|
|
|
|
"GET " => "handleGet",
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +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',
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function handleField($request)
|
|
|
|
{
|
|
|
|
return $this->Fields()->dataFieldByName($request->param('FieldName'));
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function handleSubmission($request)
|
|
|
|
{
|
|
|
|
return "Form posted";
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function handleGet($request)
|
|
|
|
{
|
|
|
|
return "Get request on form";
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|