21286 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 612 Views |
-
[SOLVED] Form submissions creating pages in CMS

24 November 2009 at 1:48am Last edited: 24 November 2009 2:37am
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);
} -
Re: [SOLVED] Form submissions creating pages in CMS

24 November 2009 at 1:59am
Should I be saving into a custom database table instead? If so, how would I do that using sapphire? Many thanks
-
Re: [SOLVED] Form submissions creating pages in CMS

24 November 2009 at 2:05am Last edited: 24 November 2009 2:37am
OK, I think I have worked it out:
I should have 2 classes: one sublcassed from Page (as I currently have) ,and one form DataObject. When I save it should be into the one from DataObject.
EDIT: yes, that solved it. Obvious when you think about it I suppose!
| 612 Views | ||
|
Page:
1
|
Go to Top |

