1 <?php
2 3 4 5 6 7 8 9 10
11 class InlineFormAction extends FormField {
12
13 protected $includeDefaultJS = true;
14
15 16 17 18 19 20
21 function __construct($action, $title = "", $extraClass = '') {
22 $this->extraClass = ' '.$extraClass;
23 parent::__construct($action, $title, null, null);
24 }
25
26 function performReadonlyTransformation() {
27 return new InlineFormAction_ReadOnly( $this->name, $this->title );
28 }
29
30 function Field() {
31 if($this->includeDefaultJS) {
32 Requirements::javascriptTemplate(SAPPHIRE_DIR . '/javascript/InlineFormAction.js',array('ID'=>$this->id()));
33 }
34
35 return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\" class=\"action{$this->extraClass}\" />";
36 }
37
38 function Title() {
39 return false;
40 }
41
42 43 44 45 46 47
48 function includeDefaultJS($bool) {
49 $this->includeDefaultJS = (bool)$bool;
50 }
51 }
52
53 54 55 56 57
58 class InlineFormAction_ReadOnly extends FormField {
59
60 protected $readonly = true;
61
62 function Field() {
63 return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\" disabled=\"disabled\" class=\"action disabled$this->extraClass\" />";
64 }
65
66 function Title() {
67 return false;
68 }
69 }
70 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-