I am probably doing this all wrong!
I have a questionnaire which I have modelled as a page, ProgrammeLaunchPage
The form works as expected, validation is OK, and when a user submits the form a record is created in the ProgrammeLaunchPage_Live table
The problem is, the page is also added to the CMS, as a blank empty entry with no page type.
What I'd like: keep the records saving into the table, but don't have the rogue pages being created.
Here is the ProgrammeLaunchPage_Controller code I use to save the submitted form values:
public function doSaveForm($data, $form) {
$success = 1;
try {
$plp = new ProgrammeLaunchPage();
$form->saveInto($plp);
$plp->write();
} catch (Exception $e) {
$success = 0;
}
Director::redirect(Director::baseURL(). $this->URLSegment . '/?success=' . $success);
}