3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 267 Views |
-
Error writing Member object in SS3

15 August 2012 at 10:02am Last edited: 19 August 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 -
Re: Error writing Member object in SS3

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
| 267 Views | ||
|
Page:
1
|
Go to Top |

