mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merged patch submitted by ajshort that calls loadDataForm on a newly created object in ModelAdmin so that properties of the object are loaded properly
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@70702 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5759314893
commit
12bd84481c
@ -670,10 +670,13 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form for editing the attached model
|
||||
* Returns a form suitable for adding a new model, falling back on the default edit form
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
public function AddForm() {
|
||||
$newRecord = new $this->modelClass();
|
||||
|
||||
if($newRecord->canCreate()){
|
||||
if($newRecord->hasMethod('getCMSAddFormFields')) {
|
||||
$fields = $newRecord->getCMSAddFormFields();
|
||||
@ -683,11 +686,12 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
|
||||
$validator = ($newRecord->hasMethod('getCMSValidator')) ? $newRecord->getCMSValidator() : null;
|
||||
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldSet (
|
||||
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
|
||||
);
|
||||
|
||||
$form = new Form($this, "AddForm", $fields, $actions, $validator);
|
||||
$form->loadDataFrom($newRecord);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user