Jump to content

Contact form


rareyush
 Share

Recommended Posts

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 

Quote

Error: Exception: Can't save page 0: /18-03-16-14-04-26-000000/: It has no parent assigned (in path\wire\core\PagesEditor.php line 469)

#0 path\wire\core\Pages.php(410): ProcessWire\PagesEditor->save(Object(ProcessWire\Page), Array)
#1 path\wire\core\Wire.php(386): ProcessWire\Pages->___save(Object(ProcessWire\Page), Array)
#2 path\wire\core\WireHooks.php(698): ProcessWire\Wire->_callMethod('___save', Array)
#3 path\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'save', Array)
#4 path\wire\core\Page.php(2376): ProcessWire\Wire->__call('save', Array)
#5 path\site\assets\cache\FileCompiler\site\modules\FormTemplateProcessor\FormTemplateProcessor.module(205): ProcessWire\Page->save()
#6 path\wire\core\Wire.php(383): FormTemplatePr

This error message was shown because: you are logged in as a Superuser. Error has been logged.

 anyone can any solutions for it ?

Link to comment
Share on other sites

Your parent page is not assigned in a correct way.

$form->parent = $page('template=contact-form'); // optional, saves form as page

should be

$form->parent = $pages->get('template=contact-form')->id; // optional, saves form as page

 

  • Like 1
Link to comment
Share on other sites

4 hours ago, flydev said:

Your parent page is not assigned in a correct way.


$form->parent = $page('template=contact-form'); // optional, saves form as page

should be


$form->parent = $pages->get('template=contact-form')->id; // optional, saves form as page

 

$form->parent = $page->get('template=contact-form')->id; // optional, saves form as page 

it does only one thing, it stops showing error but I am getting error in admin panel where I used this template "contact-form".

Link to comment
Share on other sites

18 hours ago, flydev said:

Please post the relevant errors here.

There is not error, as I mentioned I created contact form template where I save contact info like this in a page but when I created another contact page template I was getting error thanks to you error is gone but I am getting contact information saved in this page "contact".

contact image.PNG

Link to comment
Share on other sites

 

19 hours ago, rareyush said:

There is not error, as I mentioned I created contact form template where I save contact info like this in a page but when I created another contact page template I was getting error thanks to you error is gone but I am getting contact information saved in this page "contact".

Maybe that page also has a contact-form template assigned? If you do a $pages->get() it will only return the first page matching your selector , so if you have multiple pages with template "contact-form", it might not return the one you think of, but the first one PW encounters.

Link to comment
Share on other sites

6 hours ago, elabx said:

 

Maybe that page also has a contact-form template assigned? If you do a $pages->get() it will only return the first page matching your selector , so if you have multiple pages with template "contact-form", it might not return the one you think of, but the first one PW encounters.

I have only one page using " contact -form " template & I want all information there only from both contact forms.

Link to comment
Share on other sites

You have to read carefully... 

On 16.3.2018 at 9:59 AM, flydev said:

$form->parent = $pages->get('template=contact-form')->id; // optional, saves form as page

 

On 16.3.2018 at 2:02 PM, rareyush said:

$form->parent = $page->get('template=contact-form')->id; // optional, saves form as page

that's not the same ;)

  • Like 2
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...