Skip to content

Commit

Permalink
ENHANCEMENT GridFieldPopupForms->setValidator()
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Mar 5, 2012
1 parent 8a4a6ef commit 40abab8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion forms/gridfield/GridFieldPopupForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -76,6 +81,7 @@ public function handleItem($gridField, $request) {
*/
function setTemplate($template) {
$this->template = $template;
return $this;
}

/**
Expand All @@ -90,6 +96,7 @@ function getTemplate() {
*/
function setName($name) {
$this->name = $name;
return $this;
}

/**
Expand All @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -284,6 +307,7 @@ function doDelete($data, $form) {
*/
function setTemplate($template) {
$this->template = $template;
return $this;
}

/**
Expand Down

0 comments on commit 40abab8

Please sign in to comment.