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.

Data Model Questions

Error when trying /dev/build with own Forms....


Reply

3 Posts   965 Views

Avatar
Patrick__

8 September 2009 at 7:30pm Community Member, 8 Posts

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?

Avatar
Patrick__

8 September 2009 at 8:31pm Community Member, 8 Posts

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

Avatar
Patrick__

9 September 2009 at 1:58am Community Member, 8 Posts

Solved this one to...

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