mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
840f275235
Created a generic DataObject FormFactory interface that can be substituted in place of getCMSFields. Different FormFactories can depend on different kinds of context, such as 'Record' or 'Controller' - it's the responsibility of the code calling the factory to interpret and supply this context. The expected use-case is that rather than overriding getCMSFields(), developers can change CMS UIs by manipulating the FormFactory associated with the given DataObject. This is an experimental UI and may change before 4.0 stable is released.
36 lines
744 B
PHP
36 lines
744 B
PHP
<?php
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
use SilverStripe\Control\Controller;
|
|
|
|
/**
|
|
* A service which can generate a form
|
|
*/
|
|
interface FormFactory {
|
|
|
|
/**
|
|
* Default form name.
|
|
*/
|
|
const DEFAULT_NAME = 'Form';
|
|
|
|
/**
|
|
* Generates the form
|
|
*
|
|
* @param Controller $controller Parent controller
|
|
* @param string $name
|
|
* @param array $context List of properties which may influence form scaffolding.
|
|
* E.g. 'Record' if building a form for a record.
|
|
* Custom factories may support more advanced parameters.
|
|
* @return Form
|
|
*/
|
|
public function getForm(Controller $controller, $name = self::DEFAULT_NAME, $context = []);
|
|
|
|
/**
|
|
* Return list of mandatory context keys
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getRequiredContext();
|
|
}
|