silverstripe-framework/tests/php/Forms/GridField/GridFieldAddExistingAutocompleterTest/TestController.php
2016-12-19 16:08:19 +13:00

44 lines
1.3 KiB
PHP

<?php
namespace SilverStripe\Forms\Tests\GridField\GridFieldAddExistingAutocompleterTest;
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\GridFieldAddExistingAutocompleter;
use SilverStripe\Forms\GridField\GridFieldConfig;
use SilverStripe\Forms\GridField\GridFieldDataColumns;
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
/**
* @skipUpgrade
*/
class TestController extends Controller implements TestOnly
{
private static $allowed_actions = array('Form');
protected $template = 'BlankPage';
public function Link($action = null)
{
return Controller::join_links('GridFieldAddExistingAutocompleterTest_Controller', $action, '/');
}
public function Form()
{
/**
* @var Player $player
*/
$player = Player::get()->find('Email', 'player1@test.com');
$config = GridFieldConfig::create()->addComponents(
$relationComponent = new GridFieldAddExistingAutocompleter('before'),
new GridFieldDataColumns()
);
$field = new GridField('testfield', 'testfield', $player->Teams(), $config);
return new Form($this, 'Form', new FieldList($field), new FieldList());
}
}