2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest;
|
|
|
|
|
|
|
|
use SilverStripe\Control\Controller;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\Form;
|
|
|
|
use SilverStripe\Forms\GridField\GridField;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldEditButton;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldToolbarHeader;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldViewButton;
|
|
|
|
|
2017-07-03 02:21:27 +02:00
|
|
|
/**
|
|
|
|
* @skipUpgrade
|
|
|
|
*/
|
2016-10-14 03:30:05 +02:00
|
|
|
class TestController extends Controller implements TestOnly
|
|
|
|
{
|
2017-06-22 12:50:45 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
if (Controller::has_curr()) {
|
|
|
|
$this->setRequest(Controller::curr()->getRequest());
|
|
|
|
}
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function Link($action = null)
|
|
|
|
{
|
|
|
|
return Controller::join_links('GridFieldDetailFormTest_Controller', $action, '/');
|
|
|
|
}
|
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $allowed_actions = ['Form'];
|
2016-12-16 05:34:21 +01:00
|
|
|
|
|
|
|
protected $template = 'BlankPage';
|
|
|
|
|
|
|
|
public function Form()
|
|
|
|
{
|
|
|
|
$group = PeopleGroup::get()
|
|
|
|
->filter('Name', 'My Group')
|
|
|
|
->sort('Name')
|
|
|
|
->First();
|
|
|
|
|
|
|
|
$field = new GridField('testfield', 'testfield', $group->People());
|
|
|
|
$field->getConfig()->addComponent(new GridFieldToolbarHeader());
|
|
|
|
$field->getConfig()->addComponent(new GridFieldAddNewButton('toolbar-header-right'));
|
|
|
|
$field->getConfig()->addComponent(new GridFieldViewButton());
|
|
|
|
$field->getConfig()->addComponent(new GridFieldEditButton());
|
2017-05-17 07:40:13 +02:00
|
|
|
/** @skipUpgrade */
|
2016-12-16 05:34:21 +01:00
|
|
|
$field->getConfig()->addComponent($gridFieldForm = new GridFieldDetailForm($this, 'Form'));
|
|
|
|
$field->getConfig()->addComponent(new GridFieldEditButton());
|
2017-05-17 07:40:13 +02:00
|
|
|
/** @skipUpgrade */
|
2016-12-16 05:34:21 +01:00
|
|
|
return new Form($this, 'Form', new FieldList($field), new FieldList());
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|