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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Form Renderwith doesn't show form or any styling


Go to End


719 Views

Avatar
Fraser

Community Member, 48 Posts

25 July 2012 at 5:14pm

I am trying to render a form with template with the following:

function FacebookForm($fbFields) {

		$actions = new FieldSet(
			new FormAction('doFaceBookForm', 'Register')
		);

		$memberfields = singleton('XEUser')->getMemberFormFields();

		$fields = new FieldSet();
		$reqFields = array();
		foreach($fbFields as $key => $value){
			switch($value){
				case 'Gender':
					$fields->push($memberfields->fieldByName('Gender'));
					$reqFields[] = 'Gender';
					break;
				case 'DateOfBirth':
					$fields->push($memberfields->fieldByName('DateOfBirth'));
					$reqFields[] = 'DateOfBirth';
					break;
			}
		}
		$validator = new RequiredFields($reqFields);

		$form = new Form($this, 'FaceBookForm', $fields, $actions,$validator);
		$form->disableSecurityToken();
		
		return $form->renderWith(array('FacebookController','Page'));
		//return $form;

	}

When I just

return $form
my form appears but in the default contentController.ss so I created a new template and added
return $form->renderWith(array('FacebookController','Page'));
. When I do this, I get everything that should be in the page but with no styles being applied at all and the form doesn't even appear. Here is my FacebookController template:

<div id="left">
	
	<h2>Thankyou for signing up with your Facebook account</h2>
	<p>The following details could not be obtained from your Facebook account, please enter them now.</p>
	$form
</div>

<div id="right">

</div>

anyone shed any light on this?