|
75 | 75 | * @package bootstrap_extra_fields |
76 | 76 | * @subpackage forms |
77 | 77 | */ |
78 | | -class BootstrapAjaxModalForm extends BootstrapModalForm { |
| 78 | +class BootstrapAjaxModalForm extends BootstrapModalForm |
| 79 | +{ |
79 | 80 |
|
80 | 81 |
|
81 | 82 |
|
82 | | - public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){ |
83 | | - |
| 83 | + public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction) |
| 84 | + { |
84 | 85 | parent::__construct( |
85 | 86 | $controller, |
86 | 87 | $name, |
@@ -121,46 +122,53 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac |
121 | 122 | JS; |
122 | 123 | Requirements::customScript($js, 'BootstrapAjaxModalForm_Js_'.$this->FormName()); |
123 | 124 |
|
124 | | - if(Director::is_ajax()) $this->setTemplate('BootstrapAjaxModalForm'); |
| 125 | + if (Director::is_ajax()) { |
| 126 | + $this->setTemplate('BootstrapAjaxModalForm'); |
| 127 | + } |
125 | 128 | } |
126 | 129 |
|
127 | | - /** |
128 | | - * Return a rendered version of this form, suitable for ajax post-back. |
129 | | - * It triggers slightly different behaviour, such as disabling the rewriting of # links |
130 | | - */ |
131 | | - public function forAjaxTemplate() { |
132 | | - $view = new SSViewer(array( |
133 | | - $this->getTemplate(), |
134 | | - 'Form' |
135 | | - )); |
| 130 | + /** |
| 131 | + * Return a rendered version of this form, suitable for ajax post-back. |
| 132 | + * It triggers slightly different behaviour, such as disabling the rewriting of # links |
| 133 | + */ |
| 134 | + public function forAjaxTemplate() |
| 135 | + { |
| 136 | + $view = new SSViewer(array( |
| 137 | + $this->getTemplate(), |
| 138 | + 'Form' |
| 139 | + )); |
136 | 140 |
|
137 | | - $return = $view->dontRewriteHashlinks()->process($this); |
| 141 | + $return = $view->dontRewriteHashlinks()->process($this); |
138 | 142 |
|
139 | 143 | // Now that we're rendered, clear message |
140 | | - $this->clearMessage(); |
| 144 | + $this->clearMessage(); |
141 | 145 |
|
142 | | - return $return; |
143 | | - } |
| 146 | + return $return; |
| 147 | + } |
144 | 148 |
|
145 | | - public function AjaxReturn($request){ |
146 | | - if(!Director::is_ajax()){ |
| 149 | + public function AjaxReturn($request) |
| 150 | + { |
| 151 | + if (!Director::is_ajax()) { |
147 | 152 | return $this; |
148 | | - }else{ |
149 | | - if($this->examineFormAction($request)) return $this; |
150 | | - else return $this->forAjaxTemplate(); |
| 153 | + } else { |
| 154 | + if ($this->examineFormAction($request)) { |
| 155 | + return $this; |
| 156 | + } else { |
| 157 | + return $this->forAjaxTemplate(); |
| 158 | + } |
151 | 159 | } |
152 | 160 | } |
153 | 161 |
|
154 | | - protected function examineFormAction($request){ |
| 162 | + protected function examineFormAction($request) |
| 163 | + { |
155 | 164 | // Determine the action button clicked |
156 | 165 | $actionSet = false; |
157 | | - foreach($request->requestVars() as $paramName => $paramVal){ |
158 | | - if(substr($paramName,0,7) == 'action_'){ |
| 166 | + foreach ($request->requestVars() as $paramName => $paramVal) { |
| 167 | + if (substr($paramName, 0, 7) == 'action_') { |
159 | 168 | $actionSet = true; |
160 | 169 | break; |
161 | | - } |
| 170 | + } |
162 | 171 | } |
163 | 172 | return $actionSet; |
164 | 173 | } |
165 | | - |
166 | 174 | } |
0 commit comments