Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Forms and how to integrate them into a Silverstripe

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

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

Page: 1
Go to End
Author Topic: 2669 Views
  • Nemus
    Avatar
    Community Member
    20 Posts

    Forms and how to integrate them into a Silverstripe Link to this post

    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).

  • Simon
    Avatar
    Core Development Team
    27 Posts

    Re: Forms and how to integrate them into a Silverstripe Link to this post

    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.

  • mootaccount
    Avatar
    Community Member
    5 Posts

    Re: Forms and how to integrate them into a Silverstripe Link to this post

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

  • Hayden
    Avatar
    Core Development Team
    19 Posts

    Re: Forms and how to integrate them into a Silverstripe Link to this post

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

    <your project>/templates/email

    2669 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.