silverstripe-framework/tests/php/Control/RequestHandlingTest/FormActionController.php
Damian Mooyman 0c41a97a8b API Refactor Form request handling into FormRequestHandler
API Add HasRequestHandler interface
API Refactor Link() and url handling behaviour from Controller into RequestHandler
API RequestHandler classes now must define url_segment to have a default Link()
API Clean up redirectBack()
2017-03-10 15:04:33 +13:00

75 lines
1.8 KiB
PHP

<?php
namespace SilverStripe\Control\Tests\RequestHandlingTest;
use SilverStripe\Control\Controller;
use SilverStripe\Dev\TestOnly;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\TextField;
use SilverStripe\View\SSViewer;
class FormActionController extends Controller implements TestOnly
{
protected $template = 'BlankPage';
private static $url_segment = 'FormActionController';
private static $allowed_actions = array(
'controlleraction',
'Form',
'formactionInAllowedActions'
//'formaction', // left out, implicitly allowed through form action
);
public function controlleraction($request)
{
return 'controlleraction';
}
public function disallowedcontrollermethod()
{
return 'disallowedcontrollermethod';
}
/**
* @skipUpgrade
*/
public function Form()
{
return new Form(
$this,
"Form",
new FieldList(
new TextField("MyField")
),
new FieldList(
new FormAction("formaction"),
new FormAction('formactionInAllowedActions')
)
);
}
/**
* @param array $data
* @param Form $form Made optional to simulate error behaviour in "live" environment (missing arguments don't throw a fatal error there)
* (missing arguments don't throw a fatal error there)
* @return string
*/
public function formaction($data, $form = null)
{
return 'formaction';
}
public function formactionInAllowedActions($data, $form = null)
{
return 'formactionInAllowedActions';
}
public function getViewer($action = null)
{
return new SSViewer('BlankPage');
}
}