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.

Archive /

Our old forums are still available as a read-only archive.

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

Forms and how to integrate them into a Silverstripe


Reply


4 Posts   2881 Views

Avatar
Nemus

Community Member, 20 Posts

17 November 2006 at 10:25am

Hi people!

I'm having a lot of problems integrating simple form into a page within silverstripe. When i try to create page from admin which uses contactform or newsletter subscription form I get this error:

Warning: Cannot modify header information - headers already sent by (output started at C:\lighttpd\htdocs\cms\code\PageTypes\UserDefinedForm.php:525) in C:\lighttpd\htdocs\sapphire\core\Debug.php on line 118
ERROR:Error 512: None of these templates can be found: SubmittedFormReportField.ss At l53 in C:\lighttpd\htdocs\sapphire\core\SSViewer.php user_error(None of these templates can be found: SubmittedFormReportField.ss,512) user_error at line 53 of SSViewer.php SSViewer->__construct(SubmittedFormReportField) __construct at line 472 of ViewableData.php ViewableData->renderWith(SubmittedFormReportField) renderWith at line 39 of SubmittedFormReportField.php SubmittedFormReportField->Field() Field at line of call_user_method_array(Field,Object,Array) call_user_method_array at line 266 of ViewableData.php ViewableData->XML_val(Field,,1) XML_val at line 28 of .cacheC..lighttpd.htdocs.sapphire.templates.DefaultFieldHolder.ss include(C:\WINDOWS\.cacheC..lighttpd.htdocs.sapphire.templates.DefaultFieldHolder.ss) include at line 164 of SSViewer.php SSViewer->process(Object) process at line 474 of ViewableData.php ViewableData->renderWith(DefaultFieldHolder) renderWith at line 172 of FormField.php FormField->FieldHolder() FieldHolder at line of call_user_method_array(FieldHolder,Object,Array) call_user_method_array at line 266 of ViewableData.php ViewableData->XML_val(FieldHolder,,1) XML_val at line 77 of .cacheC..lighttpd.htdocs.sapphire.templates.TabSetFieldHolder.ss include(C:\WINDOWS\.cacheC..lighttpd.htdocs.sapphire.templates.TabSetFieldHolder.ss) include at line 164 of SSViewer.php SSViewer->process(Object) process at line 474 of ViewableData.php ViewableData->renderWith(TabSetFieldHolder) renderWith at line 37 of TabSet.php TabSet->FieldHolder() FieldHolder at line of call_user_method_array(FieldHolder,Object,Array) call_user_method_array at line 266 of ViewableData.php ViewableData->XML_val(FieldHolder,,1) XML_val at line 52 of .cacheC..lighttpd.htdocs.sapphire.templates.Includes.Form.ss include(C:\WINDOWS\.cacheC..lighttpd.htdocs.sapphire.templates.Includes.Form.ss) include at line 164 of SSViewer.php SSViewer->process(Object) process at line 474 of ViewableData.php ViewableData->renderWith(Form) renderWith at line 464 of Form.php Form->forTemplate() forTemplate at line 275 of ViewableData.php ViewableData->XML_val(EditForm,,1) XML_val at line 200 of .cacheC..lighttpd.htdocs.cms.templates.Includes.CMSMain_right.ss include(C:\WINDOWS\.cacheC..lighttpd.htdocs.cms.templates.Includes.CMSMain_right.ss) include at line 164 of SSViewer.php SSViewer->process(Object) process at line 474 of ViewableData.php ViewableData->renderWith(Array) renderWith at line 220 of LeftAndMain.php LeftAndMain->Right() Right at line 106 of LeftAndMain.php LeftAndMain->getitem(Array) getitem at line 108 of Controller.php Controller->run(Array) run at line 50 of Director.php Director->direct(/admin/getitem) direct at line 86 of main.php

Then I tried adding pagetypes the way suggested in documentation wiki but when I copy paste examples from there silverstripe crashes totally and no page can be served or edited untili delete those pages.

Is is possible that someone from team sets up small how-to which point by point describe all necessary steps to integrate simple form into silverstripe (for instance one that gathers some data and sends it via email).

Avatar
Simon

Core Development Team, 27 Posts

17 November 2006 at 1:32pm

Hmm, Your missing a required template it seems, called SubmittedFormReportField.ss ( I think we've forgotten to add it to cvs )

I'll have a look at the documentation to see if there are any errors, but we haven't had any problems so far.

Creating an email form should be extremely easy - a matter of using the inbuilt email form page types.

SubmittedFormReportField.ss contains..
<div class="reportfilter">
   $FilterForm
</div>
<div class="reports" id="FormSubmissions">
<% control Submissions %>
   <div class="report">
      <span class="label">Submitted:</span>$SubmitTime to $Recipient
      <table>
         <tr>
            <th>Field</th>
            <th>Value</th>
         </tr>
      <% control FieldValues %>
         <tr>
            <td class="field">$Title</td>
            <td class="value">$Value</td>
         </tr>
      <% end_control %>   
      </table>
   </div>
<% end_control %>
</div>

And you'll also need SubmittedFormEmail.ss (for the email to the administrator)

<html>
   <head>
      <style type="text/css">
            div.data span {
               width: 50%;
            }
         
            div.data span.left {
               text-align: right;
               font-weight: bold;
            }
            
            div.data a {
               overflow: visible;
            }
      </style>
   </head>
   <body>
      <h1>$Subject</h1>
      <p>
         The following data was submitted to the website at $Created:
      </p>
      <div class="data">
         $Body
      </div>
   </body>
</html>

Try adding these files and you should be away laughing.

Avatar
mootaccount

Community Member, 5 Posts

20 March 2007 at 9:01pm

Hi, to what directory should SubmittedFormEmail.ss go? Thanks!

Avatar
Hayden

Core Development Team, 19 Posts

22 March 2007 at 7:50pm

SubmittedFormEmail.ss should be placed with any other email templates in:

<your project>/templates/email