Created
September 14, 2012 13:13
-
-
Save jrast/3721833 to your computer and use it in GitHub Desktop.
Tutorial: FormActions selbst gebaut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CancelFormAction extends FormAction { | |
private $link; | |
public function __construct($link = '', $title = '', $form = null, $extraData = null, $extraClass = '') { | |
if(!$title) $title = _t('CancelFormAction.CANCEL', 'Cancel'); | |
$this->setLink($link); | |
parent::__construct('CancelFormAction', $title, $form, $extraData, $extraClass); | |
} | |
/** | |
* @return string Link | |
*/ | |
public function getLink() | |
{ | |
return $this->Link; | |
} | |
/** | |
* @param string $Link | |
* @return CancleFormAction $this | |
*/ | |
public function setLink($newLink) | |
{ | |
$this->Link = $newLink; | |
return $this; | |
} | |
function Field() { | |
$attributes = array( | |
'class' => 'action cancel ' . ($this->extraClass() ? $this->extraClass() : ''), | |
'id' => $this->id(), | |
'name' => $this->action, | |
'tabindex' => $this->getAttribute('tabindex'), | |
'href' => $this->getLink() | |
); | |
if($this->isReadonly()) { | |
$attributes['disabled'] = 'disabled'; | |
$attributes['class'] = $attributes['class'] . ' disabled'; | |
} | |
return $this->createTag( | |
'a', | |
$attributes, | |
$this->buttonContent ? $this->buttonContent : $this->Title() | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CancelFormAction extends FormAction { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Einfache Verwendung im Formular: | |
CancelFormAction::create($this->Link(), 'Abbrechen') | |
// Mit verketteten Funktionsaufrufen: | |
CancelFormAction::create($this->Link())->setTitle('Abbrechen')->addExtraClass('btn') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment