Jump to content

render function in contact form


rareyush
 Share

Recommended Posts

<?php namespace ProcessWire; 

	

$form = $modules->get('FormTemplateProcessor');$form->template = $templates->get('book-now'); // required
$form->requiredFields = array('title', 'email', 'number','body');
//$form->email = 'your@email.com'; // optional, sends form as email
$form->parent = $page('template=book-now'); // optional, saves form as page
//$form->render();  // draw form or process submitted form




?>

	<?php echo $form->render(); ?>

 

 

using this to for a contact on new processwire version 3  and I am receiving this error

 

Error: Uncaught Error: Call to undefined method stdClass::render() in C:\wamp64\www\mbs\site\templates\book-now.php:9

 

tried following but none of them works

 

render(array('name','email','body',))

wireRender()

 

Render()

wire()

 

anyone ?  

Link to comment
Share on other sites

The error message you posted does not fit with the code.

You got that error when you tried it with render(array('name','email','body',))

What error do you get with the actual code that you posted?

EDIT: Sorry for that

Link to comment
Share on other sites

1 hour ago, flydev said:

If you put namespace ProcessWire; on top of the module file, does it work ?

nope not working

 

 

5 minutes ago, gebeer said:

The error message you posted does not fit with the code.

You got that error when you tried it with render(array('name','email','body',))

What error do you get with the actual code that you posted?

code is here

 

<?php namespace ProcessWire; 

	

$form = $modules->get('FormTemplateProcessor');$form->template = $templates->get('book-now'); // required
$form->requiredFields = array('title', 'email', 'number','body');
//$form->email = 'your@email.com'; // optional, sends form as email
$form->parent = $page('template=book-now'); // optional, saves form as page
$form->render();  // draw form or process submitted form




?>

	<?php echo $form->render(); ?>

 

here is the error

bxhe56W.png

Link to comment
Share on other sites

I just set this up on my dev install 3.0.96 with your code from above and it works.
Only thing I changed is $form->parent...

So it is hard to say what goes wrong on your end without seeing the complete template code.

EDIT: what does this say?

$form = $modules->get('FormTemplateProcessor');
var_dump($form);

And then right before your echo?

var_dump($form);
echo $form->render();


 

  • Like 1
Link to comment
Share on other sites

43 minutes ago, gebeer said:

I just set this up on my dev install 3.0.96 with your code from above and it works.
Only thing I changed is $form->parent...

So it is hard to say what goes wrong on your end without seeing the complete template code.

EDIT: what does this say?


$form = $modules->get('FormTemplateProcessor');
var_dump($form);

And then right before your echo?


var_dump($form);
echo $form->render();


 

 

 

this error

Error: Uncaught Error: Call to a member function render() on null in C:\wamp64\www\mbs\site\templates\book-now.php:13

 

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