2016-09-07 05:39:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use SilverStripe\Admin\LeftAndMain;
|
|
|
|
use SilverStripe\View\Requirements;
|
|
|
|
use SilverStripe\Forms\Form;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
|
|
|
|
class TestReactFormBuilder extends LeftAndMain
|
|
|
|
{
|
|
|
|
private static $url_segment = 'test-react';
|
|
|
|
private static $menu_title = 'Test React FormBuilder';
|
|
|
|
|
|
|
|
public function getClientConfig()
|
|
|
|
{
|
|
|
|
$baseLink = $this->Link();
|
|
|
|
return array_merge(parent::getClientConfig(), [
|
|
|
|
'reactRouter' => false,
|
|
|
|
'form' => [
|
|
|
|
'TestEditForm' => [
|
|
|
|
'schemaUrl' => $this->Link('schema/TestEditForm'),
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
public function getTestEditForm($id = null) {
|
|
|
|
/* @var $page BasicFieldsTestPage */
|
2016-10-18 06:17:35 +02:00
|
|
|
$page = BasicFieldsTestPage::get()->First();
|
2016-09-07 05:39:43 +02:00
|
|
|
|
|
|
|
$form = Form::create($this, 'TestEditForm', $page->getCMSFields(), FieldList::create([]));
|
2016-10-18 06:17:35 +02:00
|
|
|
$form->loadDataFrom($page);
|
2016-09-07 05:39:43 +02:00
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function TestEditForm() {
|
|
|
|
return $this->getTestEditForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Implement on client
|
|
|
|
*
|
|
|
|
* @param bool $unlinked
|
|
|
|
* @return ArrayList
|
|
|
|
*/
|
|
|
|
public function breadcrumbs($unlinked = false)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEditForm($id = null, $fields = null) {
|
2017-11-06 04:56:59 +01:00
|
|
|
Requirements::javascript('silverstripe/frameworktest: client/dist/js/legacy.js');
|
2016-09-07 05:39:43 +02:00
|
|
|
|
|
|
|
return Form::create($this, 'TestEditForm', FieldList::create(), FieldList::create());
|
|
|
|
}
|
|
|
|
}
|