mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
API CHANGE: Allow definition of DataObject::getCMSAddFormFields() to alter modeladmin step 1
BUGFIX: Allow use of CheckboxSetField and other many-many editors in the add form of ModelAdmin BUGFIX: Fix direct access of (class)/(id)/edit on the ModelAdmiN git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61505 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2da4e8a66a
commit
4870a9f340
@ -547,7 +547,11 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
*/
|
||||
public function AddForm() {
|
||||
$newRecord = new $this->modelClass();
|
||||
$fields = $newRecord->getCMSFields();
|
||||
if($newRecord->hasMethod('getCMSAddFormFields')) {
|
||||
$fields = $newRecord->getCMSAddFormFields();
|
||||
} else {
|
||||
$fields = $newRecord->getCMSFields();
|
||||
}
|
||||
|
||||
$validator = ($newRecord->hasMethod('getCMSValidator')) ? $newRecord->getCMSValidator() : null;
|
||||
|
||||
@ -561,6 +565,8 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
function doCreate($data, $form, $request) {
|
||||
$className = $this->getModelClass();
|
||||
$model = new $className();
|
||||
// We write before saveInto, since this will let us save has-many and many-many relationships :-)
|
||||
$model->write();
|
||||
$form->saveInto($model);
|
||||
$model->write();
|
||||
|
||||
@ -604,9 +610,13 @@ class ModelAdmin_RecordController extends Controller {
|
||||
if(Director::is_ajax()) {
|
||||
return $this->EditForm()->forAjaxTemplate();
|
||||
} else {
|
||||
return $this->parentController->parentController->customise(array(
|
||||
'EditForm' => $this->EditForm()
|
||||
))->renderWith('LeftAndMain');
|
||||
// This is really quite ugly; to fix will require a change in the way that customise() works. :-(
|
||||
return$this->parentController->parentController->customise(array(
|
||||
'Right' => $this->parentController->parentController->customise(array(
|
||||
'EditForm' => $this->EditForm()
|
||||
))->renderWith('ModelAdmin_right')
|
||||
))->renderWith(array('ModelAdmin','LeftAndMain'));
|
||||
return ;
|
||||
}
|
||||
} else {
|
||||
return "I can't find that item";
|
||||
|
Loading…
Reference in New Issue
Block a user