Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Editing DataObject in the frontend

Go to End

2 Posts   1238 Views


Community Member, 2 Posts

14 April 2014 at 11:07am

I'm needing help creating a form for the frontend where the user can edit a DataObject.

The website is basically a planner, so the user has a project (or projects) assigned to them. The projects are made up of 9 steps which the user works through gradually. Where I'm stuck is giving the user the ability to edit the Project dataobjects "Title" and "Description".

Here's what I have so far:

Edit project form

public function EditProjectForm() {
        $projectID = (int) $this->request->param('ID');
	$project = Project::get()->byID($projectID);
	$project->ProjectID = $project->ID;
	$fields = new FieldList(
		TextField::create('Title', 'Project Title'),
		TextareaField::create('Description', 'Project Description'),
		FileField::create('ProjectImage', 'ProjectImage'),
		TextField::create('Category', 'Category'),
	$actions = new FieldList(
		FormAction::create("doEdit", 'Submit changes')
	$form = new Form($this, 'EditProjectForm', $fields, $actions); 
	return $form;

doEdit Action

public function doEdit($data, Form $form) {
        $projectID = $data['ProjectID'];
		$project = Project::get()->byID($projectID);


        $project->Title = $data['Title'];
        $project->Description = $data['Description'];




This creates the form fine, and populates the form with the projects information. But when I click doEdit it just goes to a blank white page at

I'm really stuck on this, and given I'm very much a beginner to PHP this is a major headache...


Forum Moderator, 1890 Posts

30 April 2014 at 1:09am

The "offical" method for 2.4 is genericviews -
I Think this is mostly going to work on 3.x too.