2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms\Tests\GridField\GridField_URLHandlerTest;
|
|
|
|
|
2022-10-17 06:58:20 +02:00
|
|
|
use SilverStripe\Control\HTTPResponse;
|
2016-10-14 03:30:05 +02:00
|
|
|
use SilverStripe\Control\RequestHandler;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\Form;
|
|
|
|
use SilverStripe\Forms\FormAction;
|
|
|
|
use SilverStripe\Forms\TextField;
|
|
|
|
use SilverStripe\View\SSViewer;
|
|
|
|
|
|
|
|
class TestComponent_ItemRequest extends RequestHandler
|
|
|
|
{
|
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $allowed_actions = ['Form', 'showform', 'testpage'];
|
2016-12-16 05:34:21 +01:00
|
|
|
|
|
|
|
protected $gridField;
|
|
|
|
|
|
|
|
protected $link;
|
|
|
|
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
public function __construct($gridField, $id, $link)
|
|
|
|
{
|
|
|
|
$this->gridField = $gridField;
|
|
|
|
$this->id = $id;
|
|
|
|
$this->link = $link;
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2017-03-02 03:24:38 +01:00
|
|
|
public function Link($action = null)
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
|
|
|
return $this->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function showform()
|
|
|
|
{
|
|
|
|
return "<head>" . SSViewer::get_base_tag("") . "</head>" . $this->Form()->forTemplate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Form()
|
|
|
|
{
|
|
|
|
return new Form(
|
|
|
|
$this,
|
2017-03-02 03:24:38 +01:00
|
|
|
Form::DEFAULT_NAME,
|
2016-12-16 05:34:21 +01:00
|
|
|
new FieldList(
|
|
|
|
new TextField("Test")
|
|
|
|
),
|
|
|
|
new FieldList(
|
|
|
|
new FormAction('doAction', 'Go')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-10-17 06:58:20 +02:00
|
|
|
public function doAction(array $data, Form $form): HTTPResponse
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
2022-10-17 06:58:20 +02:00
|
|
|
return HTTPResponse::create()->setBody("Submitted " . $data['Test'] . " to item #" . $this->id);
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testpage()
|
|
|
|
{
|
|
|
|
return "Test page for item #" . $this->id;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|