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.

Data Model Questions /

Error writing Member object in SS3


Reply


3 Posts   585 Views

Avatar
solartom

Community Member, 4 Posts

15 August 2012 at 10:02am

Edited: 19/08/2012 10:59am

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

Avatar
Willr

Forum Moderator, 5513 Posts

17 August 2012 at 8:19pm

What is the error message you get?

Avatar
solartom

Community Member, 4 Posts

18 August 2012 at 9:33am

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