Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Howto create/cusotmize ur own user definedform?

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

Page: 1
Go to End
Author Topic: 1161 Views
  • plautzer
    Avatar
    Community Member
    7 Posts

    Howto create/cusotmize ur own user definedform? Link to this post

    HI,

    Id like to create some specific user forms for my site. I tried the userdefinedform module which is great to handle in the admin area but lacks the ability to design and apply ur own template to the form.

    I therefore started to create my own user form following these 2 tutorials:
    http://blog.mike-wittje.de/2009/06/11/formularerstellung-mit-silverstripe/
    http://www.ssbits.com/creating-a-simple-contact-form/

    Now I would like to add the tabs and functionality simialr to the userdefinedfrom to my form:

    class SampleFormPage extends Page
    {

       static $db = array(

          'Mailto' => 'Varchar(100)',
          'SubmitText' => 'Text'

       );

       static $has_many = array(
          "Submissions" => "SubmittedForm",
          "EmailRecipients" => "UserDefinedForm_EmailRecipient"
       );

       function getCMSFields() {

          $fields = parent::getCMSFields();

          // define tabs
          $fields->findOrMakeTab('Root.Content.EmailRecipients', _t('EMAILRECIPIENTS', 'Email Recipients'));
          $fields->findOrMakeTab('Root.Content.OnComplete', _t('ONCOMPLETE', 'On Complete'));
          $fields->findOrMakeTab('Root.Content.Submissions', _t('SUBMISSIONS', 'Submissions'));

             

          // view the submissions
          $fields->addFieldToTab("Root.Content.Submissions", new CheckboxField('DisableSaveSubmissions',_t('SAVESUBMISSIONS',"Disable Saving Submissions to Server")));
          $fields->addFieldToTab("Root.Content.Submissions", new SubmittedFormReportField( "Reports", _t('RECEIVED', 'Received Submissions'), "", $this ) );

          // who do we email on submission

          $emailRecipients = new ComplexTableField(

             $this,
           'EmailRecipients',
           'EmailRecipient',
           array(

                'EmailAddress' => _t('EMAILADDRESS', 'Email'),

                'EmailSubject' => _t('EMAILSUBJECT', 'Subject'),

                'EmailFrom' => _t('EMAILFROM', 'From')

           ),

           'getCMSFields_forPopup',

             "FormID = '$this->ID'"

          );

          

          $emailRecipients->setAddTitle(_t('AEMAILRECIPIENT', 'A Email Recipient'));
          $fields->addFieldToTab("Root.Content.EmailRecipients", $emailRecipients);

          // text to show on complete
          $onCompleteFieldSet = new FieldSet(

             new HtmlEditorField( "OnCompleteMessage", _t('ONCOMPLETELABEL', 'Show on completion'),3,"",_t('ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this )

          );

          $fields->addFieldsToTab("Root.Content.OnComplete", $onCompleteFieldSet);

          return $fields;   

       }

    }

    class SampleFormPage_Controller extends Page_Controller
    {

    function SampleForm()
    {

    return new SampleForm($this,'SampleForm');

    }

    }

    The tabs appear but I won't get the email adding, the onsubmission text and the submission to work.
    Can anyone help me out, show where i can find the answer or even know a better way to about this?

    Your will be very much appreciated...
    Plautzer

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