mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace SilverStripe\Forms\Tests\FormFactoryTest;
|
||
|
|
||
|
use SilverStripe\Control\Controller;
|
||
|
use SilverStripe\Forms\Form;
|
||
|
use SilverStripe\ORM\DataObject;
|
||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||
|
|
||
|
/**
|
||
|
* Edit controller for this form
|
||
|
*/
|
||
|
class TestController extends Controller
|
||
|
{
|
||
|
private static $extensions = [
|
||
|
ControllerExtension::class,
|
||
|
];
|
||
|
|
||
|
public function Link($action = null)
|
||
|
{
|
||
|
return Controller::join_links(
|
||
|
'FormFactoryTest_TestController',
|
||
|
$action,
|
||
|
'/'
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function Form()
|
||
|
{
|
||
|
// Simple example; Just get the first draft record
|
||
|
$record = $this->getRecord();
|
||
|
$factory = new EditFactory();
|
||
|
return $factory->getForm($this, 'Form', ['Record' => $record]);
|
||
|
}
|
||
|
|
||
|
public function save($data, Form $form)
|
||
|
{
|
||
|
// Noop
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return DataObject
|
||
|
*/
|
||
|
protected function getRecord()
|
||
|
{
|
||
|
return Versioned::get_by_stage(TestObject::class, Versioned::DRAFT)->first();
|
||
|
}
|
||
|
}
|