silverstripe-framework/Forms/FormFactory.php
Damian Mooyman 840f275235 API Created a generic FormFactory interface (#6178)
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.
2016-10-20 12:42:24 +13:00

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();
}