Jump to:

3432 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Error writing Member object in SS3

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

Page: 1
Go to End
Author Topic: 474 Views
  • solartom
    Avatar
    Community Member
    4 Posts

    Error writing Member object in SS3 Link to this post

    Hello,

    I'm new to silverstripe and I decided to try out Silverstripe 3. I created a basic registration form and everything worked in Silverstripe 2.4 but I get an error in Silverstripe 3. I probably missed something that needs to be changed to work in 3 but I haven't been able to find it so far.

    Any help would be greatly appreciated

    Here's the code:

    class ArtistRegPage extends Page
    {
       static $db = array();
       static $has_one = array();
    }

    class ArtistRegPage_Controller extends Page_Controller
    {
       function form()
       {
          $fields = new FieldList(
          new TextField('FirstName','First Name'),
          new TextField('Surname','Last Name'),
          new EmailField('Email','Email Address'),
          new ConfirmedPasswordField('Password')
          );
          
          $actions = new FieldList(new FormAction('doArtistRegister','Submit'));
          $validator = new RequiredFields('FirstName', 'SurName', 'Email', 'Password');
          $form = new Form(
                $this,
                'Form',
                $fields,
                $actions,
                $validator
                );
          return $form;
       }
       
       function doArtistRegister($data, $form)
       {
          $artist = new Artist();
          $form->saveInto($artist);
          $form->sessionMessage('Form successfully submitted', 'Good');
          $artist->write();
          return $this->redirectBack();
       }
    }


    Note: It works fine if comment out $artist->write(). Also the same problem occurs if I use Member instead of Artist.

    Thanks,
    Tom

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Error writing Member object in SS3 Link to this post

    What is the error message you get?

  • solartom
    Avatar
    Community Member
    4 Posts

    Re: Error writing Member object in SS3 Link to this post

    I did some more tracking down of the error and found out it was a validation error. I was using an existing email address. I will need to read up more on validation to make sure the error is correctly reported to the user.

    Thanks,
    Tom

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