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

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • 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.
    • By creativejay
      I'm displaying a list of products which are found by their templates, but the pages are taking a very long time to load. At first, I blamed it on my image rendering (using PIM2), but even with all those images now stored in the file tree, the page is taking abysmally long to load. ProCache seems to help but I don't feel as though what I'm trying to do should be gnawing the bones of my resources quite so long.
      The variable for the selector is defined in my header include:
      $productCatList="prod_series|prod_series_ethernet|prod_series_access|prod_series_accessories|prod_series_fiber|prod_series_pwr_supplies|prod_series_pwr_systems|prod_series_wireless"; $getCurrentProdOptions="template=$productCatList, prod_status_pages!=1554|1559|1560|4242"; Then in the template for the page upon which the directory loads:
      $products = $pages->find("$getCurrentProdOptions"); include_once("./prod-list-row.inc"); echo $out; And the prod-list-row.inc foreach (which is on every page that's exhibiting the slowdown):
      <?php $sum = 0; $out =""; $out .= "<div class='span_12_of_12'>\n"; foreach($products as $p){ $sum += 1; if ($sum % 2 == 0) { $bgcolor = '#fff'; } else { $bgcolor = '#e4e4e4';} $par = $p->parent; $out .="<div class='section group' style='background: $bgcolor ; min-height: 110px'>\n"; $img = $p->prod_image; $thumb = $img->pim2Load('squarethumb100')->canvas(100,100,array(0,0,0,0),'north',0)->pimSave()->url; $out .="<div data-match-height='{$p->title}' class='col span_2_of_12 hide'>"; $out .="<a href='{$p->url}'><span class='product-image-box'><img src='{$thumb}' alt='{$p->title}' title='{$p->title}'></span></a>"; $out .= "</div>"; $out .= "<div data-match-height='{$p->title}' class='col span_6_of_12'>"; $out .= "<div class='prod-list-name-label'><a href='{$p->url}'>{$p->title}</a></div>"; if($page!=$par) { $out .= "<div class='prod-list-category-label' style='font-size: .7em;'>Category: <a href='{$par->url}'>{$par->title}</a></div>"; } $out .= "<div class='list-headline' style='font-size: .8em;'>{$p->headline}</div>"; $out .="<div class='learn-more-buttons-sm'>"; $out .="<a href='{$p->url}' title='Product Specs and Documentation'><span class='find-out-more-button' style='font-size: .8em;'><i style='font-size: .8em;' class='fa fa-lightbulb-o' ></i> &nbsp; Learn More</span></a>"; $out .="</div>"; $out .="</div> \n"; $out .= " <div data-match-height='{$p->title}' class='col span_4_of_12'>"; if(count($p->prod_feat_imgs) >0 ){ $out .= "<div class='featured-icons-list' margin: 2em .5em;'>"; foreach($p->prod_feat_imgs as $feat){ $icon = $pages->get("$feat->prod_featicon_pages"); if($icon->image) { if($feat->prod_feat_textlang) { $icontitle = $feat->prod_feat_textlang;} else {$icontitle = $icon->title;} $out .= "<img src='".$icon->image->size(35,35,$imgOptions)->url . "' alt='" . $icontitle . "' title='" . $icontitle . "' class='listing-feat-icon' style='margin-right: .5em;' />"; } } $out .= "</div>"; if($p->prod_product_line){ foreach($p->prod_product_line as $pline) if($pline->image) { $out .= "<div style='height: 35px;'>\n"; $out .= "<img src='{$pline->image->size(75,35,$imgOptions)->url}' alt='{$pline->title}' />"; $out .= "</div>"; } } } $out .= "</div>"; $out .="</div>"; } $out .= "</div>";  
      Is there a clear culprit here of what I'm doing that's so stressing the system?
      I turned off TracyDebugger because I saw another thread about that causing slowdown (even though I'm using the latest), but that had no effect. Every time I thought I found the culprit and commented it out, nothing changed.
      Would appreciate some more eyes on this. Thank you!
      ETA: prod_feat_imgs is a repeater field which contains a Page reference field (from which I pull the image and title) and a multilanguage textfield (to override the page reference title if it exists). Could that be the problem?
×
×
  • Create New...