mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allowing custom popup requirements in ComplexTableField without subclassing through $requirementsForPopupCallback
MINOR Added getParentController() to TableListField_ItemRequest and ComplexTableField_Popup MINOR Extending ComplexTableField_ItemRequest from TableListField_ItemRequest to avoid redundant code (from r100774) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105649 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9f6bf696c6
commit
e78dc5273d
@ -35,8 +35,7 @@ class ComplexTableField extends TableListField {
|
||||
* - A FieldSet object: Use that field set directly.
|
||||
* - A method name, eg, 'getCMSFields': Call that method on the child object to get the fields.
|
||||
*/
|
||||
|
||||
protected $addTitle;
|
||||
protected $addTitle;
|
||||
|
||||
protected $detailFormFields;
|
||||
|
||||
@ -107,6 +106,13 @@ class ComplexTableField extends TableListField {
|
||||
* This is set by javascript and used by greybox.
|
||||
*/
|
||||
protected $popupCaption = null;
|
||||
|
||||
/**
|
||||
* @var callback A function callback invoked
|
||||
* after initializing the popup and its base calls to
|
||||
* the {@link Requirements} class.
|
||||
*/
|
||||
public $requirementsForPopupCallback = null;
|
||||
|
||||
/**
|
||||
* @var $detailFormValidator Validator
|
||||
@ -684,7 +690,7 @@ JS;
|
||||
* @package forms
|
||||
* @subpackage fields-relational
|
||||
*/
|
||||
class ComplexTableField_ItemRequest extends RequestHandler {
|
||||
class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
|
||||
protected $ctf;
|
||||
protected $itemID;
|
||||
protected $methodName;
|
||||
@ -697,14 +703,7 @@ class ComplexTableField_ItemRequest extends RequestHandler {
|
||||
function Link($action = null) {
|
||||
return Controller::join_links($this->ctf->Link(), '/item/', $this->itemID, $action);
|
||||
}
|
||||
|
||||
function __construct($ctf, $itemID) {
|
||||
$this->ctf = $ctf;
|
||||
$this->itemID = $itemID;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function index() {
|
||||
return $this->show();
|
||||
}
|
||||
@ -1082,12 +1081,25 @@ class ComplexTableField_Popup extends Form {
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
|
||||
|
||||
// Append requirements from instance callbacks
|
||||
$callback = $this->getParentController()->getParentController()->requirementsForPopupCallback;
|
||||
if($callback) call_user_func($callback, $this);
|
||||
|
||||
// Append requirements from DataObject
|
||||
// DEPRECATED 2.4 Use ComplexTableField->requirementsForPopupCallback
|
||||
if($this->dataObject->hasMethod('getRequirementsForPopup')) {
|
||||
$this->dataObject->getRequirementsForPopup();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ComplexTableField_ItemRequest
|
||||
*/
|
||||
function getParentController() {
|
||||
return $this->controller;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1484,5 +1484,12 @@ class TableListField_ItemRequest extends RequestHandler {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TableListField
|
||||
*/
|
||||
function getParentController() {
|
||||
return $this->ctf;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user