2016-12-16 05:34:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms\Tests\FormFactoryTest;
|
|
|
|
|
2017-05-09 04:09:48 +02:00
|
|
|
use SilverStripe\Control\RequestHandler;
|
2016-12-16 05:34:21 +01:00
|
|
|
use SilverStripe\Forms\DefaultFormFactory;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\FormAction;
|
|
|
|
use SilverStripe\Forms\HiddenField;
|
|
|
|
use SilverStripe\Forms\TextField;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test factory
|
|
|
|
*/
|
2017-05-09 04:09:48 +02:00
|
|
|
class EditFormFactory extends DefaultFormFactory
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
|
|
|
private static $extensions = [
|
|
|
|
ControllerExtension::class
|
|
|
|
];
|
|
|
|
|
2017-05-09 04:09:48 +02:00
|
|
|
protected function getFormFields(RequestHandler $controller = null, $name, $context = [])
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
|
|
|
$fields = new FieldList(
|
|
|
|
new HiddenField('ID'),
|
|
|
|
new TextField('Title')
|
|
|
|
);
|
|
|
|
$this->invokeWithExtensions('updateFormFields', $fields, $controller, $name, $context);
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
2017-05-09 04:09:48 +02:00
|
|
|
protected function getFormActions(RequestHandler $controller = null, $name, $context = [])
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
|
|
|
$actions = new FieldList(
|
|
|
|
new FormAction('save', 'Save')
|
|
|
|
);
|
|
|
|
$this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context);
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
}
|