2016-10-20 12:42:24 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2017-05-04 14:07:51 +12:00
|
|
|
use SilverStripe\Control\RequestHandler;
|
2016-10-20 12:42:24 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A service which can generate a form
|
|
|
|
*/
|
2016-11-29 12:31:16 +13:00
|
|
|
interface FormFactory
|
|
|
|
{
|
2016-10-20 12:42:24 +13:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
/**
|
|
|
|
* Default form name.
|
|
|
|
*/
|
|
|
|
const DEFAULT_NAME = 'Form';
|
2016-10-20 12:42:24 +13:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
/**
|
|
|
|
* Generates the form
|
|
|
|
*
|
2017-05-04 14:07:51 +12:00
|
|
|
* @param RequestHandler $controller Parent controller
|
2016-11-29 12:31:16 +13:00
|
|
|
* @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
|
|
|
|
*/
|
2017-05-04 14:07:51 +12:00
|
|
|
public function getForm(RequestHandler $controller = null, $name = self::DEFAULT_NAME, $context = []);
|
2016-10-20 12:42:24 +13:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
/**
|
|
|
|
* Return list of mandatory context keys
|
|
|
|
*
|
2016-12-12 15:25:18 +13:00
|
|
|
* @return array
|
2016-11-29 12:31:16 +13:00
|
|
|
*/
|
|
|
|
public function getRequiredContext();
|
2016-10-20 12:42:24 +13:00
|
|
|
}
|