code/forms/GridFieldAddClassesButton.php 1 location
|
@@ 215-231 (lines=17) @@
|
| 212 |
|
* @param GridField $grid |
| 213 |
|
* @return null |
| 214 |
|
*/ |
| 215 |
|
public function handleAdd($grid) { |
| 216 |
|
$classes = $this->getClassesCreate($grid); |
| 217 |
|
if(empty($classes)) { |
| 218 |
|
throw new SS_HTTPResponse_Exception(400); |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
// Add item to gridfield |
| 222 |
|
$list = $grid->getList(); |
| 223 |
|
foreach($classes as $class) { |
| 224 |
|
$item = $class::create(); |
| 225 |
|
$item->write(); |
| 226 |
|
$list->add($item); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
// Should trigger a simple reload |
| 230 |
|
return null; |
| 231 |
|
} |
| 232 |
|
} |
| 233 |
|
|
code/forms/GridFieldAddNewClassesList.php 1 location
|
@@ 146-161 (lines=16) @@
|
| 143 |
|
* @param Array $data from request |
| 144 |
|
* @return null |
| 145 |
|
*/ |
| 146 |
|
public function handleAdd($grid, $data) { |
| 147 |
|
$class = $this->getSelectedClass($data); |
| 148 |
|
|
| 149 |
|
if(!$class) { |
| 150 |
|
throw new SS_HTTPResponse_Exception(400); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
// Add item to gridfield |
| 154 |
|
$list = $grid->getList(); |
| 155 |
|
$item = $class::create(); |
| 156 |
|
$item->write(); |
| 157 |
|
$list->add($item); |
| 158 |
|
|
| 159 |
|
// Should trigger a simple reload |
| 160 |
|
return null; |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
/** |
| 164 |
|
* Gets the default class that is selected automatically. |