Jump to content
rareyush

render function in contact form

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 ?  

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

what happens if you comment out the first call to $form->render?

Share this post


Link to post
Share on other sites

and this is definitely wrong


$form->parent = $page('template=book-now'); // wrong
$form->parent = $pages->get('template=book-now'); // should work

 

Share this post


Link to post
Share on other sites
8 minutes ago, gebeer said:

what happens if you comment out the first call to $form->render?

same error with different line number 

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

don't you get anything from the var_dump?

Share this post


Link to post
Share on other sites

what does this say when you put it before everything else?

var_dump($modules->isInstalled('FormTemplateProcessor'));

 

  • Like 2

Share this post


Link to post
Share on other sites
On 4/13/2018 at 5:54 PM, gebeer said:

what does this say when you put it before everything else?


var_dump($modules->isInstalled('FormTemplateProcessor'));

 

it solved my problem

thanks

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By christophengelmayer
      Hi everyone,
      I'm working on a CLI script that renders paginated pages.
      Therefore I iterate trough paginated pages and set the page number and render the result.
      My problem is, after calling the render function for the first time, the output doesn't change even if I change the page number.
       
      DEMO:
      I'm using a template that renders a pagination of its children:
      <?php echo $page->children("limit=3")->render(); ?> I can view the paginated results in the Browser:
      /page-rendering-pagination/ /page-rendering-pagination/page2 /page-rendering-pagination/page3 ... When trying to render the different pages using the API I always get the first result, even if I change the page Number.
      <?php namespace ProcessWire; include('./index.php'); wire('input')->setPageNum(1); $p = wire('pages')->get('/page-rendering-pagination'); var_dump($p->render()); // renders first three items wire('input')->setPageNum(2); var_dump($p->render()); // also renders the first three items Am I missing something? Is there some kind of caching mechanism that I'm not aware of?
      Thanks for your help.
    • By Lance O.
      I've built a site that uses parent pages as the "container" for child pages:
      Parent page [page.php] -- Child page [unit-child-a.php] -- Child page [unit-child-b.php] ---- Grandchild page [subunit-grandchild-a.php] ---- Grandchild page [subunit-grandchild-b.php] -- Child page [unit-child-c.php] The child pages are displayed as content on the corresponding parent page using the render method. Some child pages also include their own child pages. (Internally the child page template names start with "unit-" and the grandchild page template names start with "subunit-".)
      Example:
      foreach ($page->children("template=template-name,sort=sort") as $child) echo $child->render(); This approach allows content administrators to add and reorder child pages as necessary, but I've come across an issue that I'm not sure how to address.
      The site includes search functionality, but when a visitor searches for content and it is found in a child or grandchild page, the Parent page should be the one that is displayed in the search results, since the child and grandchild pages are not directly viewable. Since some searches could include more than one child or grandchild page of a parent page, this sometimes means that a parent page could be included more than once.
      How do I easily redirect the child and grandchild pages to the parent page, and only include the parent page once in the search results?
       
    • By rareyush
      I created a template where I am rendering this php file where I am saving contact quires in a template and it is working fine in homepage.
      I used my same code in another page on a same project by creating another template and rendering another file but I am receiving this error again and again, I tried to figure out but it not working.
       
      <?php namespace ProcessWire; $form = $modules->get('FormTemplateProcessor');$form->template = $templates->get('contact'); // required $form->requiredFields = array('title', 'fullname','email_form', 'mobile', 'message'); //$form->email = 'your@email.com'; // optional, sends form as email $form->parent = $page('template=contact-form'); // optional, saves form as page $form->render(); // draw form or process submitted form ?> <?php echo $form->render(); ?>  
      error I am receiving 
       anyone can any solutions for it ?
    • By ov3rtak3r
      Hello everyone!
      I am new to Processwire and really like it, but now I have a problem that I can't solve by myself.
      I have created following templates:
      data_people (no template-file)
      person_listing (person_listing.php)
      person_detail (person_detail.php)

      I have added the following Pages:
      Actor, Director, Stuff using template person_listing.php [visible in frontend]
      "People" using template data_people [not visible, only for data]
      -> "Georg Klonee" using template person_detail [is visible, but should not be shown using path /en/person/georg-klonee]

      Example Person: Georg Klonee
      The Problem:
      He is a Actor and a Director, so I want him to be shown in the Listing of /en/actors and /en/directors. No problem until here - it works. But now, when I click him, the URL for the Detail-Page is unfortunately /en/person/georg-klonee. But I want it to be /en/actors/georg-klonee, if i open the details from Actors-Page (and of course /en/directors/georg-klonee when on Directors-Page).
      How can I get this to work? I am also using TemplateEngine-Module with TemplateTwigEngine-Module, hopefully this won't be a problem? I tried it with URL-Segments for person_listing.php. But how can I abort the rendering of people_listing and start rendering person_detail.php?
       
      Thanks for your help in advance.
×
×
  • Create New...