10393 Posts in 2203 Topics by 1714 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 830 Views |
-
Saving into the multi form

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
-
Re: Saving into the multi form

4 November 2010 at 12:06am
Really stuck on this, if any one could help that would be great.
-
Re: Saving into the multi form

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
-
Re: Saving into the multi form

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();
| 830 Views | ||
|
Page:
1
|
Go to Top |


