Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Error when trying /dev/build with own Forms....

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

Page: 1
Go to End
Author Topic: 939 Views
  • Patrick__
    Avatar
    Community Member
    8 Posts

    Error when trying /dev/build with own Forms.... Link to this post

    Hello! After going through the basic tutorials, i tried to build my own Forms. But ran into the following error:

    Errormessage:
    http://www.fotos-hochladen.net/ssproblem1afv71q3m.jpg
    Trace:
    http://www.fotos-hochladen.net/ssproblem2etj8on4m.jpg

    The page is rendered.

    The code for my form:
    Feedback.php

    <?php
    class Feedback extends Page {
       static $db = array();
       static $has_one = array();
    }

    class Feedback_Controller extends Page_Controller
    {
       function FeedbackForm() {
       //DropdownField Thema implementieren
       $source = array('Kritik' => 'Kritik', 'Anregungen' => 'Anregungen', 'Kommentare' => 'Kommentare');
       $ddfield = new DropdownField('Thema');
       $ddfield->setSource($source);
       $ddfield->setHasEmptyDefault(true);
       
       $fields = new FieldSet(
             new TextField('Name'),
             new EmailField('EMAIL'),
             new TextField('Berufsbezeichnung'),
             $ddfield,
             new TextareaField($name="description", $title="Anregung", $rows=5, $cols=10, $value=""),
             new TextareaField($name="cusAdvantage", $title="Auf welche Weise wäre dieses Produktmerkmal für Sie vorteilhaft?", $rows=5, $cols=10, $value=""),
             new TextareaField($name="featureAlreadyExists", $title="Haben sie dieses Merkmal schon bei einem anderen Produkt gesehen? Wenn ja , wo?", $rows=5, $cols=10, $value=""),
             new CheckboxField($name="answer", $title="Möchten Sie eine Antwort auf ihre Anregung erhalten?"),
             new CheckboxField($name="newsletter", $title="Möchten Sie sich für den kostenlosen Newsletter eintragen?")
          );   
          $actions = new FieldSet(new FormAction('doSubmitFeedback','Abschicken'));
          return new Form($this, 'CustomerFeedback', $fields,    $actions);
       }

       function doSubmitFeedback($data, $form) {
          $submitted = new FeedbackSubmission();
          $form->saveInto($submitted);
          $submitted->write();
          Director::redirectBack();
       }
    }
    ?>

    FeedbackSubmission.php

    <?php
    class FeedbackSubmission extends DataObject {
       static $db = array(
                'Name' => 'Text',
                'EMAIL' => 'Text',
                'Berufsbezeichnung' => 'Text',
                'Thema' => 'Text',
                'description' => 'Text',
                'cusAdvantage' => 'Text',
                'featureAlreadyExists' => 'Text',
                'answer' => 'Text',
                'newsletter' => 'Text'   
       );
    }
    ?>

    Feedback.ss //located in /Templates/Layout and integrated in the page.ss from Tutorial 3

    <div id="Content" class="typography">
       $FeedbackForm
    </div>

    Anything i did wrong?

  • Patrick__
    Avatar
    Community Member
    8 Posts

    Re: Error when trying /dev/build with own Forms.... Link to this post

    Ok, problem solved... but now i have the next one.

    The Tables at the database are created, but the formdata is not written into them.

    Same code as above...

  • Patrick__
    Avatar
    Community Member
    8 Posts

    Re: Error when trying /dev/build with own Forms.... Link to this post

    Solved this one to...

    the Form which i returned in "function FeedbackForm()" had a different name than the function itself and the template marker...

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