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.

All other Modules /

Discuss all other Modules here.

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

Recaptcha Module Question

Go to End



Community Member, 45 Posts

21 November 2009 at 11:04am

I got the Racaptcha Module working, however, I cannot seem to get the theme parameter to work properly. My code is below. Anyone else have this same problem?

function GetInvolvedForm() {

$recaptchaField = new RecaptchaField('MyCaptcha');
$recaptchaField->jsOptions = array('theme' => 'clean'); // optional
		return new Form($this, "GetInvolvedForm", new FieldSet(
			// List the your fields here
			new LiteralField("literalfield","<div class=\"clearfix\" style=\"margin-bottom:20px;\">"),
			new CheckboxSetField("ContactTypeList","Please check the following areas for which you are contacting us:",
				Dataobject::get("ContactType")->toDropdownMap("Name", "Description")
			new LiteralField("literalfield","</div>"),
			new TextField("NameFirst", "First Name *"),
			new TextField("NameLast", "Last Name *"),
			new TextField("PhoneHome", "Home Phone *"),
			new TextField("PhoneCell", "Cell Phone"),
			new EmailField("Email", "Email *"),
			new TextField("Address", "Address"),
			new TextField("City", "City"),
			new DropdownField("State", "State", Dataobject::get("FormState")->toDropdownMap("StateName", "StateName"),$value = null,$form=null,$emptyOption="Select"),
			new TextField("ZipCode", "Zip Code"),
			new DropdownField("Province", "Province", Dataobject::get("FormProvince")->toDropdownMap("ProvinceName", "ProvinceName"),$value = null,$form=null,$emptyOption="Select"),
			new DropdownField("Country", "Country", Dataobject::get("FormCountry")->toDropdownMap("CountryName", "CountryName"),$value = null,$form=null,$emptyOption="Select"),
			new TextareaField("Comment", "Comment"),
			new HiddenField("GetInvolvedPageID", "", $this->ID)//,
			//new HiddenField ("Referrer", "", $_SERVER['HTTP_REFERER'])
		), new FieldSet(
		// List the action buttons here
			new FormAction("process", "Submit")
		), new RequiredFields(
		// List the required fields here: "Email", "FirstName"
	function process( $data, $form ) {
		$submittedForm = new Contact();
		//replace array commas with space after so string can return down to next line in reports
		//do not use carriage returns, will cause issues with csv export
		$submittedForm->ContactTypeList = str_replace(',', ', ', $submittedForm->ContactTypeList);

		//iterate through ContactTypeList array for print friendly in the email
		$printedContactTypeList = '<br/>';
		foreach ($data['ContactTypeList'] as $k=>$v) {
			$printedContactTypeList .= $v . '<br />';
		$data['ContactTypeList'] = $printedContactTypeList;

		//send notifcation email
		$From = $this->EmailNotificationFrom;
		$To = $this->EmailNotificationTo;
		$Subject = $this->EmailNotificationSubject;  
		$email = new Email($From, $To, $Subject);
		//set template
		//populate template
		//send mail
	  	//return to submitted message

		$url = "/get-involved-thank-you/";