2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Action button with confirmation text.
|
|
|
|
* These button are useful for things like delete buttons.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage actions
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class ConfirmedFormAction extends FormAction {
|
|
|
|
protected $confirmation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new action button.
|
|
|
|
* @param action The method to call when the button is clicked
|
|
|
|
* @param title The label on the button
|
|
|
|
* @param confirmation The message to display in the confirmation box?
|
|
|
|
* @param form The parent form, auto-set when the field is placed inside a form
|
|
|
|
*/
|
|
|
|
function __construct($action, $title = "", $confirmation = "Are you sure?", $form = null) {
|
|
|
|
$this->confirmation = $confirmation;
|
|
|
|
parent::__construct($action, $title, $form);
|
|
|
|
}
|
2008-09-17 01:14:31 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function Field() {
|
2008-04-06 06:08:45 +02:00
|
|
|
$attributes = array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'class' => $this->extraClass(),
|
|
|
|
'id' => $this->id(),
|
2008-04-09 13:21:22 +02:00
|
|
|
'name' => $this->Name(),
|
2008-04-06 06:08:45 +02:00
|
|
|
'value' => $this->attrTitle(),
|
2008-09-17 01:14:31 +02:00
|
|
|
'tabindex' => $this->getTabIndex(),
|
2008-04-06 06:08:45 +02:00
|
|
|
'onclick' => "return confirm('$this->confirmation');"
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->createTag('input', $attributes);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|