Jump to:

23472 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Update table in database with populated user form

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

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

Page: 1
Go to End
Author Topic: 2103 Views
  • Todd
    Avatar
    31 Posts

    Update table in database with populated user form Link to this post

    Hi All,

    I can populate a user form and I now how to submit it into a table i the database, but how do I update with the information I retrieved? This is assuming I make a change to one of the populated fields, like correcting a spelling error or modifying a date.

    I use this function to submit new info to the database:

       function submitform($data, $form) {

                // Create a new Member object and load the form data into it
                $submission = new StudentData();
                $form->saveInto($submission);

                // Write it to the database. This needs to happen before we add it to a group
                $submission->write();
             
                Director::redirectBack();
                
          }

    I'm guessing a fairly simple modification of the function above will allow me to update my table with my currently populated fields.

    Thanks in advance.

  • JimAasheim
    Avatar
    Community Member
    12 Posts

    Re: Update table in database with populated user form Link to this post

    Hey,
    that's exactly my problem as well.
    I'd be glad for the hint also.

    I see that the objects ID is not available in the form (if I force it then I get a dropdown list with all IDs (or actually filled with the return values of the getTitle() function).

    I also noticed there's a SecurityID field - but I couldn't yet find out about its meaning.

    Well, I'll post here as I find the solution... before someone else posts it... ;-)

    2103 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.