mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE Removed deprecated EditForm classa
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64371 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
050321cb3c
commit
f7a0c5db04
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Creates an edit form on a site page.
|
|
||||||
* Extends the basic form class to automatically look up, and save to, the data-object referred to
|
|
||||||
* by controller->data().
|
|
||||||
* @package forms
|
|
||||||
* @subpackage core
|
|
||||||
* @deprecated I'm not sure if this is in production use? Is this a legacy of a bygone era?
|
|
||||||
*/
|
|
||||||
class EditForm extends Form {
|
|
||||||
function __construct($controller, $name, FieldSet $fields) {
|
|
||||||
|
|
||||||
$this->data = $controller->data();
|
|
||||||
|
|
||||||
$actions = new FieldSet(
|
|
||||||
new FormAction("save", _t('Form.SAVECHANGES', "Save Changes"))
|
|
||||||
);
|
|
||||||
|
|
||||||
$sequential = $fields->dataFields();
|
|
||||||
|
|
||||||
foreach($sequential as $field) {
|
|
||||||
$fieldName = $field->Name();
|
|
||||||
// echo "<li>$fieldName";
|
|
||||||
$field->setValue($this->data->$fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::__construct($controller, $name, $fields, $actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form handler. Saves all changed fields to the database, and returns back to the
|
|
||||||
* index action of the given object
|
|
||||||
*/
|
|
||||||
function save($params) {
|
|
||||||
$record = $this->controller->data();
|
|
||||||
|
|
||||||
foreach($this->fields as $field) {
|
|
||||||
$fieldName = $field->Name();
|
|
||||||
if(isset($params[$fieldName])) {
|
|
||||||
$record->$fieldName = $params[$fieldName];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$record->write();
|
|
||||||
Director::redirect($this->controller->Link());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user