Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT GridFieldPopupForms->setValidator()

  • Loading branch information...
commit 40abab8aecbbd1c9c3e1dde53f3fd085252a6fcb 1 parent 8a4a6ef
@chillu chillu authored
Showing with 25 additions and 1 deletion.
  1. +25 −1 forms/gridfield/GridFieldPopupForms.php
View
26 forms/gridfield/GridFieldPopupForms.php
@@ -25,6 +25,11 @@ class GridFieldPopupForms implements GridField_URLHandler {
*/
protected $name;
+ /**
+ * @var Validator The form validator used for both add and edit fields.
+ */
+ protected $validator;
+
function getURLHandlers($gridField) {
return array(
'item/$ID' => 'handleItem',
@@ -76,6 +81,7 @@ public function handleItem($gridField, $request) {
*/
function setTemplate($template) {
$this->template = $template;
+ return $this;
}
/**
@@ -90,6 +96,7 @@ function getTemplate() {
*/
function setName($name) {
$this->name = $name;
+ return $this;
}
/**
@@ -98,6 +105,21 @@ function setName($name) {
function getName() {
return $this->name;
}
+
+ /**
+ * @param Validator $validator
+ */
+ public function setValidator(Validator $validator) {
+ $this->validator = $validator;
+ return $this;
+ }
+
+ /**
+ * @return Validator
+ */
+ public function getValidator() {
+ return $this->validator;
+ }
}
class GridFieldPopupForm_ItemRequest extends RequestHandler {
@@ -205,7 +227,8 @@ function ItemEditForm() {
->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'),
FormAction::create('doDelete', _t('GridFieldDetailsForm.Delete', 'Delete'))
->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive')
- )
+ ),
+ $this->component->getValidator()
);
$form->loadDataFrom($this->record);
@@ -284,6 +307,7 @@ function doDelete($data, $form) {
*/
function setTemplate($template) {
$this->template = $template;
+ return $this;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.