Jump to content

Form Template Processor success message in different languages


Fran
 Share

Recommended Posts

I've created a field in the contact page (id:1032) so I can write different success messages according to the language.

I'm trying this for the success message in the Form Template Processor module, but without any success:

90. // message output upon successful completion of the form
91. $this->set('successMessage', '<h2>' echo $pages->get(1032)->message_sent '</h2>'); 

it gives me this error:

Parse Error: syntax error, unexpected 'echo' (T_ECHO) (line 91 of /home/islak/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module) 

What am I doing wrong?

Thanks guys... :)

Link to comment
Share on other sites

  On 2/15/2016 at 8:11 PM, tpr said:

The error message is pretty verbose... try

$this->set('successMessage', '<h2>' . $pages->get(1032)->message_sent . '</h2>'); 

I tried this one out and it gives me a different error now:

Error: Call to a member function get() on a non-object (line 91 of /home/islak/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module)

the idea is to use the form in several pages, that's why i'm trying to get the field from the page's ID

Link to comment
Share on other sites

  On 2/15/2016 at 9:23 PM, tpr said:

Try wire('pages') instead $pages :)

It's not working either...

Maybe it has to do with the fact that this line is a part of a function? I don't know. I'm not really an expert in php.

The function would be:

public function init() {

		// create a page for holding our form fields
		$this->contact = new Page();

		// Template to use for the contact form fields (required).
		// must be a Template object, it will be assigned to $this->contact.
		$this->set('template', null);

	 	// Optional E-Mail address that form will get submitted to
		$this->set('email', '');

		// Array of field names that are required to complete the submission
		// if not specified, it will use the admin field settings.
		// I recommend that you make at least one field required, since this 
		// isn't an admin setting yet.
		$this->set('requiredFields', array());

	 	// Array of field names that should be skipped when drawing the form
		$this->set('skipFields', array('title'));

		// Subject of the email that gets sent 
		$this->set('emailSubject', 'Islandika Contacto Web'); 

		// Optional parent page for the contact.
		// If ommited, the page will not be saved to the DB.
		$this->set('parent', null);

		// message output upon successful completion of the form
		$this->set('successMessage', '<h2>' . wire('pages')->get(1032)->message_sent . '</h2>'); 

		// date format used for the title's of newly created contact pages
		$this->set('dateFormat', 'F j, Y, g:i a'); 

	}
Link to comment
Share on other sites

I've just realized that it works if we use the path instead of the ID, which was not working:

// message output upon successful completion of the form
		$this->set('successMessage', '<h2>' . wire('pages')->get('contact')->message_sent . '</h2>'); 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...