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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Saving into the multi form


Go to End


4 Posts   1530 Views

Avatar
Harley

Community Member, 165 Posts

2 November 2010 at 2:00am

Hi there,

I've used the Multi form module in the past once before but an earlier version. I'm just looking through the docs http://doc.silverstripe.org/modules:multiform and there doesn't seem to be a proper explanation of how to save the data for each step of the form, instead it just talks about the "Member" and "Organisation" dataobjects.

I've been using this

				if($step->class == 'StartCaseStep') {
					$StartCase = new StartCase();
					$data = $step->loadData();
					if($data){
						$StartCase->update($data);
						$StartCase->write();
					}
				}

...but to no avail

Any help here is greatly appreciated

Thanks

Avatar
Harley

Community Member, 165 Posts

4 November 2010 at 12:06am

Really stuck on this, if any one could help that would be great.

Avatar
Harley

Community Member, 165 Posts

4 November 2010 at 2:40pm

Sorry to be going on about this again but...

Anyone got any idea when the documentation is going to be extended to include how to "saveInto" with this form? I noticed it on the to do list but I'm getting really curious.

I can't seem to get the steps to save because I'm getting a "Fatal error: Call to a member function saveInto() on a non-object" which suggests to me that it cannot find the table to write into.

When I browse the database using phpMyAdmin I noticed that the class name and the table name are different? I have named the class names with the word "step" appended, eg "FirstStep" but in the database the table name will be "First". Could this be the conflict?

Thanks

Avatar
Bambii7

Community Member, 254 Posts

27 November 2010 at 10:29pm

Hi Harley,
did you get to the bottom of the error?

Is the example code in your first post in the form action function?
saveInto takes a maped object and auto populates the dataobjects fields.

From the api "Save the contents of this form into the given data object." http://api.silverstripe.org/2.4/forms/core/Form.html

Here is a basic example I've been working on
/**
* This function is called when the user submits the form.
*/
function UpdateAction($data, $form) {
if($member = Member::currentUser()) {
$form->saveInto($member);
$member->write();
}
Director::redirectBack();
}

You can either use the form object to saveInto or use the dataobjects update funtion

$DataObject = get_one('DataObject');
$DataObject->update($data);
$form->saveInto($DataObject);
$DataObject->write();