silverstripe-framework/tests/php/Control/RequestHandlingTest/FormActionController.php

75 lines
1.8 KiB
PHP
Raw Normal View History

2016-10-14 03:30:05 +02:00
<?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';
2016-10-14 03:30:05 +02:00
private static $url_segment = 'FormActionController';
private static $allowed_actions = array(
'controlleraction',
'Form',
'formactionInAllowedActions'
//'formaction', // left out, implicitly allowed through form action
);
2016-10-14 03:30:05 +02:00
public function controlleraction($request)
{
return 'controlleraction';
}
2016-10-14 03:30:05 +02:00
public function disallowedcontrollermethod()
{
return 'disallowedcontrollermethod';
}
2016-10-14 03:30:05 +02:00
/**
* @skipUpgrade
*/
public function Form()
{
return new Form(
$this,
"Form",
new FieldList(
new TextField("MyField")
),
new FieldList(
new FormAction("formaction"),
new FormAction('formactionInAllowedActions')
)
);
}
2016-10-14 03:30:05 +02:00
/**
* @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';
}
2016-10-14 03:30:05 +02:00
public function formactionInAllowedActions($data, $form = null)
{
return 'formactionInAllowedActions';
}
2016-10-14 03:30:05 +02:00
public function getViewer($action = null)
{
return new SSViewer('BlankPage');
}
2016-10-14 03:30:05 +02:00
}