Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Saving into the multi form

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1011 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Saving into the multi form Link to this post

    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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Saving into the multi form Link to this post

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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Saving into the multi form Link to this post

    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

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Saving into the multi form Link to this post

    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();

    1011 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.