miradoro Posted June 12, 2012 Share Posted June 12, 2012 hi how do i add 2 custom fields on contact form? Prestashop Version: 1.4.8.2 Link to comment Share on other sites More sharing options...
Greek Geek Goddess Posted June 12, 2012 Share Posted June 12, 2012 Try this: The simplest method for the html is to just hard-code your additional fields in the template file contact-form.tpl. To actually process the form you will need to create an override for the controller by ceating a file called ContactController.php in /<web-root>/<your-optional-ps-folder>/override/controller containing something like: <?php class ContactController extends ContactControllerCore { function preProcess() { if (Tools::isSubmit('submitMessage')) { // The form has been submitted so your field validation code goes in here. // Get the entered values for your fields using Tools::getValue('<field-name>') // Flag errors by adding a message to $this->errors e.g. $this->errors[] = Tools::displayError('I haven't even bothered to check!'); } parent::preProcess(); if (Tools::isSubmit('submitMessage') && is_empty($this->errors)) { // Success so now perform any addition required actions // Note that the only indication of success is that $this->errors is empty } } } http://stackoverflow.com/questions/10320382/how-to-customize-register-and-contact-forms-in-prestashop Link to comment Share on other sites More sharing options...
miradoro Posted June 12, 2012 Author Share Posted June 12, 2012 hi Thanks for your help in contact-form.tpl i added <!-- 2 new fields --> <p><label for="contactperson">{l s='Name'}</label> <input type="text" id="contactperson" name="contactperson" value="{if isset($contactperson)}{$contactperson|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> <p><label for="companyname">{l s='Company'}</label> <input type="text" id="companyname" name="companyname" value="{if isset($companyname)}{$companyname|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> how will ContactController.php look like then? Link to comment Share on other sites More sharing options...
Greek Geek Goddess Posted June 12, 2012 Share Posted June 12, 2012 Use the code I pasted above (add the closing tag I forgot it) and/or follow the link I got it from. They have the complete details there and how to upload it. http://stackoverflow...s-in-prestashop Once everything is uploaded to the correct folders test it out. PS - always save your orignal file somewhere before making any edits. That way if it doesn't work, you can always revert to the old one that did. Link to comment Share on other sites More sharing options...
miradoro Posted June 12, 2012 Author Share Posted June 12, 2012 i did copy the file as it was after clicking on submit i get HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. my override looks like this <?php class ContactController extends ContactControllerCore { function preProcess() { if (Tools::isSubmit('submitMessage')) { $this->errors[] = Tools::displayError('I havent even bothered to check!'); } parent::preProcess(); if (Tools::isSubmit('submitMessage') && is_empty($this->errors)) { } } } Link to comment Share on other sites More sharing options...
Greek Geek Goddess Posted June 12, 2012 Share Posted June 12, 2012 Sorry I didn't test the code before I sent it. Let me play with it and see if I can get it to parse correctly without the error. Link to comment Share on other sites More sharing options...
miradoro Posted June 12, 2012 Author Share Posted June 12, 2012 thank you...pls let me know your findings Link to comment Share on other sites More sharing options...
Recommended Posts