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.

Form Questions /

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

Marketo Form Integration


Go to End


4 Posts   2643 Views

Avatar
VictorH

Community Member, 29 Posts

1 May 2012 at 7:03am

Edited: 01/05/2012 7:05am

I created the form below which simply sends out a couple of emails. I need to update it so that it submits to Marketo. Does anyone have any experience? I've attached the PHP code (renamed marketo.txt so that I would be able to upload it) supplied by Market but I'm now sure where to start. Any help would be appreciated.

Here's the code of the current form.

public function SignUpForm() {
		// Sign Up Form Fields
		$fields = new FieldSet(
			new TextField('firstname','First Name*'),
			new TextField('lastname','Last Name*'),			
			new TextField('creditunion', 'Credit Union*', $this->getSearchQuery()),
			new EmailField('email','E-mail address*'),
			new TextField('city','City*'),
			new DropdownField('state', 'State', array(
				'' => 'State',
				'AL' => 'Alabama',
				'AK' => 'Alaska',
				'AZ' => 'Arizona'
	        )),
	        new HiddenField ('cn', 'CN') 
		);
		
		// On Submit
		$actions = new FieldSet(
			new FormAction('doSignUp', 'Submit')
		);
		
		// Fields to validate
		$validator = new RequiredFields('firstname', 'lastname', 'creditunion', 'email');

		return new Form($this, 'SignUpForm', $fields, $actions, $validator);
	}

	function doSignUp($data, $form) {		
		// Send Email to Admin
		
		// Send Email to User
		
		Director::redirect(Director::baseURL(). $this->URLSegment . "/?signupsuccess=1");
	}

Attached Files
Avatar
NicoHaase

Community Member, 6 Posts

1 May 2012 at 7:33pm

It shouldn't be that difficult: at the point where you send out the mail (in doSignup), you integrate the call to Marketo (whatever that service does). Copy the code from the branch starting with if ($isPostback), modify the parameters you pass (eg $_REQUEST['email'] could become $data['email'], as all fields contained in the form are represented in $data), and you should be done :)

Avatar
VictorH

Community Member, 29 Posts

1 May 2012 at 7:45pm

Thanks for the reply.

I'm getting ready to do what you recommend but before I do wanted to ask about the code below which appears after ($isPostback). I noticed that it contains references to a class (mktSampleMktowsClient) in the rest of the code. Where and when do I integrate that class?

# USER_ID and SECRET_KEY need to be created through Marketo web interface and pasted on lines 999 and 1000 of this file
	$accessKey = mktSampleMktowsClient::MKTOWS_USER_ID;
	$secretKey = mktSampleMktowsClient::MKTOWS_SECRET_KEY;

	// !!! SET END POINT TO YOUR CUSTOMER SPECIFIC URL, CAN BE FOUND IN MARKETO ADMIN INTERFACE !!!
	$soapEndPoint = 'https://na-n.marketo.com/soap/mktows/1_7';

	# a mktSampleMktowsClient object is created to make all the web service calls
	$client = new mktSampleMktowsClient($accessKey, $secretKey, $soapEndPoint);

Avatar
NicoHaase

Community Member, 6 Posts

1 May 2012 at 8:11pm

Just create a new file for that class, besides the file in which your form occurs, and run /dev/build.