Skip to content

Commit

Permalink
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/…
Browse files Browse the repository at this point in the history
…branches/2.3@70734 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Normann Lou authored and Sam Minnee committed Feb 2, 2011
1 parent c7a03db commit 20e829a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions code/ModelAdmin.php
Expand Up @@ -670,32 +670,28 @@ function add($request) {
}

/**
* Returns a form suitable for adding a new model, falling back on the default edit form
*
* @return Form
* Returns a form for editing the attached model
*/
public function AddForm() {
$newRecord = new $this->modelClass();

if($newRecord->canCreate()){
if($newRecord->hasMethod('getCMSAddFormFields')) {
$fields = $newRecord->getCMSAddFormFields();
} else {
$fields = $newRecord->getCMSFields();
}

$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;
}
}
}

function doCreate($data, $form, $request) {
$className = $this->getModelClass();
Expand Down

0 comments on commit 20e829a

Please sign in to comment.