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.

All other Modules /

Discuss all other Modules here.

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

Cannot use User Forms Module


Go to End
Reply


10 Posts   2788 Views

Avatar
Marco_D

Community Member, 20 Posts

14 May 2009 at 8:18pm

Hello community,

currently I am trying out the User Forms Module.
After creating a new User Defined Form, I'm clicking on the tab "Form".
I attached a screenshot of my frontend, something seems to be wrong: It does not look like the frontend that can be seen in the user forms module documentation. When clicking on "Text" or "Checkbox" nothing happens.

Can somebody help me?

Regards
Marco

Attached Files
Avatar
George

Community Member, 41 Posts

14 May 2009 at 8:27pm

Hello,

I have not the same problem on 2.3.1, but after installing userforms trunk 76665 the fields are not anymore ordered correctly in the cms.

An other problem is that I get a server error when I open a page with forms. An error that I haven't before. The error message is "Object::__call() Method 'setCustomValidationMessage' not found in class 'TextField'". Any ideas?

Avatar
SalvaStripe

Community Member, 89 Posts

14 May 2009 at 10:17pm

Edited: 14/05/2009 10:20pm

i dont use form or userdefinedform from the cms.. i do write them by my own.
when i write a contact form, it will send emails AND save the query into DB as an dataobject. so later i can write a code that shows me all querys or such..

here example for one of my contact forms:

mysite/code/KontaktObjekt.php

<?php

class KontaktObjekt extends DataObject {
   static $db = array(
      'IhrName' => 'Text',
      'Email' => 'Text',
      'Message' => 'Text',
      'Date' => 'Text',
   );
}

?>

mysite/code/KontaktFormular.php

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

class KontaktFormular_Controller extends Page_Controller {

   function init() {
      parent::init();
      
      Requirements::themedCSS("pms");
   }

   function SendenForm() {
         $fieldset = new FieldSet(
            new TextField(
               $name = "IhrName",
               $title = "Ihr Name",
               $value = ""
            ),
             new EmailField (
               $name = "Email",
               $title= "Ihre Emailadresse",
               $value = "@"
            ),
            new TextareaField(
               $name = "Message",
               $title = "Ihre Nachricht",
               $rows = 10,
               $cols = 40,
               $value = "Nachricht eingeben"
            ),
             new HiddenField (
               $name = "Date",
               $title= "Datum",
               $value = time()
            )
         );
         
      $actions = new FieldSet(
         new FormAction('doSenden', 'Senden')
      );
      
      $validator = new RequiredFields('IhrName', 'Email', 'Message');
      return new Form($this, 'SendenForm', $fieldset, $actions);
   }

   function doSenden($data, $form) {
      $submission = new KontaktObjekt();
      $form->saveInto($submission);
      $submission->write();
      
      $result = DB::query("SELECT * FROM KontaktObjekt ORDER BY ID DESC LIMIT 1");
      foreach($result as $value) {
      };
         
         $extra = "From: ".$value['IhrName']." <".$value['Email'].">\n";
         $extra .= "Content-Type: text/html\n";
         $Datum = date("d.m.Y",$value['Date']);
         $empfaenger = "YOUR@MAIL.COM";
         $betreff = "Nachricht vom Kontaktformular";
         $text = '
<br >
<table width="600" align="center" cellpadding="8">
<tr>
<td><h1><center>YOUR COMPANY</center></h1></td>
</tr>
<tr>
<td><strong>Von:</strong> '.$value['IhrName'].'</td>
</tr>
<tr>
<td><strong>Email:</strong> '.$value['Email'].'</td>
</tr>
<tr>
<td><strong>Nachricht:</strong><br >'.nl2br($value['Message']).'</td>
</tr>
<tr>
<td><strong>Datum:</strong> '.$value['Created'].'</td>
</tr>
</table>
         ';
         mail($empfaenger, $betreff, $text, $extra);
//         mail($value['Email'], $betreff, $text, $extra);
         
      Director::redirectBack();
   }
   
}

?>

themes/YOURTHEME/templates/Layout/KontaktFormular.ss
here just insert this Line anywhere you want:

$SendenForm

Okay, is not totaly silverstripe compliant, but it works fine. i am learning all the new cool stuff from 2.3.1, so soon i will make the code much more elegant.

here is short excurs:
When you define the DataObjekt, you can create a field in DB with some options to choose..

<?php

class Bewerberdata extends DataObject {
   static $db = array(
      'CanYourSpeakItaliano' => "Enum('No,Just a little bit,Yes,Mother-Tongue')"
   );
}

?>

0==================================================0

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

class Bewerbermaske_Controller extends Page_Controller {

   function SendenForm() {
         $fieldset = new FieldSet(
            new DropdownField(
               'CanYourSpeakItaliano',
               'Can Your Speak Italiano?',
               singleton('Bewerberdata')->dbObject('CanYourSpeakItaliano')->enumValues()
            )
         );
      }
...
...
...

0==================================================0

Avatar
SalvaStripe

Community Member, 89 Posts

14 May 2009 at 10:36pm

hm i found this thread..
http://silverstripe.org/general-questions/show/260293#post260293

1. there is an example, how to make the code fine
2. at last i found a good way to show "message send" messages after sendig. with the session.. omg why i did not think for sessions^^

Avatar
Willr

Forum Moderator, 5513 Posts

15 May 2009 at 1:04pm

You will need to use SS2.3.2 or greater for userforms to work.

Avatar
Marco_D

Community Member, 20 Posts

15 May 2009 at 6:33pm

@willr:
I am using userforms-v0.1.0, its description on www.silverstripe.org/modules includes that only SilverStripe 2.3.0+ is needed.
Maybe, you have thought I am dealing with a newer version of User Forms?

Avatar
Big Bang Creative

Community Member, 92 Posts

4 June 2009 at 9:41pm

I'm running SS v2.3.1 and I have downloaded User Forms [v0.1.0]. I dropped the whole folder into root and did a db build.

The screenshot in the first thread is exactly what I see on the "Forms" tab. Is there a fix for this?

Avatar
Willr

Forum Moderator, 5513 Posts

4 June 2009 at 9:48pm

V0.1? You will have more luck using SSv2.3.2 and using the new 0.2 release of userforms. Looking at that screenshot I would think that one of the core css files or js files has not been uploaded correctly. Try recopy the files and then running yoursite.com/admin?flush=1

Go to Top