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.

Form Questions /

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

Howto create/cusotmize ur own user definedform?

Go to End



Community Member, 10 Posts

17 March 2010 at 2:25am


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:

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(


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

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

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



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