Jump to:

10851 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » Cannot use User Forms Module

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 2507 Views
  • Marco_D
    Avatar
    Community Member
    20 Posts

    Cannot use User Forms Module Link to this post

    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
  • George
    Avatar
    Community Member
    41 Posts

    Re: Cannot use User Forms Module Link to this post

    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?

  • SalvaStripe
    Avatar
    Community Member
    89 Posts

    Re: Cannot use User Forms Module Link to this post

    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

  • SalvaStripe
    Avatar
    Community Member
    89 Posts

    Re: Cannot use User Forms Module Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Cannot use User Forms Module Link to this post

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

  • Marco_D
    Avatar
    Community Member
    20 Posts

    Re: Cannot use User Forms Module Link to this post

    @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?

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: Cannot use User Forms Module Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Cannot use User Forms Module Link to this post

    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

    2507 Views
Page: 1 2
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.