News:

Looking for documentation? Take a look on our wiki

Main Menu

Add extra Fields to Ask a Question

Started by Hugu, May 21, 2014, 23:36:32 PM

Previous topic - Next topic

Hugu

Hello!

I'm trying to add some extra fields to the "ask a question form", text and combo box. I've searched the forum for solutions, and I've been following other posts about this subject, but I'm getting a "Invalid Token" error when submitting the form.
I would like to ask for your kind help to try to solve this problem.
I am no coder but here is what I have done so far:

file form.php

<label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_NAME')  ?> : <input type="text" class="validate[required,minSize[4],maxSize[100]]" value="<?php echo $this->user->name ?>" name="name" id="name" size="30"  validation="required name"/></label>
         <br />
         <label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_EMAIL')  ?> : <input type="text" class="validate[required,custom[email]]" value="<?php echo $this->user->email ?>" name="email" id="email" size="30"  validation="required email"/></label>
         <br/>
          <label><?php echo JText::_('COM_VIRTUEMART_SHOPPER_FORM_PHONE')  ?> : <input type="text" class="validate[required,custom[phone]]" value="<?php echo $this->phone ?>" name="phone" id="phone" size="30"  validation="required phone"/></label></form>
<p></p><form action=""> <label><?php echo JText::_('COM_VIRTUEMART_OPTION_FORM_PRODUCT')  ?> :
<select name="Object">
<option value="Object1">Object1</option>
<option value="Object2">Object2</option>
<option value="Object3">Object3</option>
<option value="Object4">Object4</option>
<option value="Object5">Object5</option>
<option value="Object6">Object6</option>
<option value="Object7">Object7</option>
<option value="Other">Other</option>
</select>
</form></label>
<label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_SIZE')  ?> : <input type="text" class="validate[required,minSize[1],maxSize[50]]" value="<?php echo $this->user->size ?>" name="size" id="size" size="30"  validation="required size"/></label>
         <br/>
<p></p>
<form action=""><label><?php echo JText::_('COM_VIRTUEMART_OPTION_GLASS')  ?> :
<select name="Glass">
<option value="Glass1">Glass1</option>
<option value="Glass2">Glass2</option>
<option value="Glass3">Glass3</option>
</select>
</form></label>
<p></p>
<form action=""><label><?php echo JText::_('COM_VIRTUEMART_PASS1')  ?> :
<select name="Pass">
<option value="Pass1">Pass1</option>
<option value="Pass2">Pass2</option>
<option value="Pass3">Pass3</option>
</select>
</form></label>
<form ><label><?php echo JText::_('COM_VIRTUEMART_PASS')  ?> : <input type="text" value="<?php echo $this->user->pass ?>" name="pass" id="pass" size="30" /></label><p></p>
         <label>


file view.html.php

      $this->setLayout ('mail_html_question');
      $this->comment = JRequest::getString ('comment');
      $this->phone = JRequest::getString ('phone');
      $this->object = JRequest::getString ('object');
      $this->size = JRequest::getString ('size');
      $this->glass = JRequest::getString ('glass');
      $this->pass = JRequest::getString ('pass');
      $this->pass1 = JRequest::getString ('pass1');


file mail_raw_question:

echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user->name, $this->user->email, $this->user->phone, $this->user->object, $this->user->size, $this->user->glass, $this->user->pass $this->user->pass1) . "\n";


file mail_html_question:

<?php
defined('_JEXEC') or die('');
$this->phone = JRequest::getString ('phone');
$this->object = JRequest::getString ('object');
$this->size = JRequest::getString ('size');
$this->glass = JRequest::getString ('glass');
$this->pass = JRequest::getString ('pass');
$this->pass1 = JRequest::getString ('pass1');
?>
<td valign="top" width="100%">
    <?php
   echo JText::sprintf('COM_VIRTUEMART_QUESTION_MAIL_FROM', $this->user['name']) . "<br />";
   echo JText::_('COM_VIRTUEMART_USER_FORM_EMAIL') . " : " . $this->user['email'] . "<br />";
   echo JText::_('COM_VIRTUEMART_SHOPPER_FORM_PHONE') . " : " . $this->user['phone'] . "<br />";
   echo JText::_('COM_VIRTUEMART_OPTION_FORM_PRODUCT') . " : " . $this->user['object'] . "<br />";
   echo JText::_('COM_VIRTUEMART_OPTION_FORM_SIZE') . " : " . $this->user['size'] . "<br />";
   echo JText::_('COM_VIRTUEMART_OPTION_GLASS') . " : " . $this->user['glass'] . "<br />";
   echo JText::_('COM_VIRTUEMART_PASS') . " : " . $this->user['pass'] . "<br />";
   echo JText::_('COM_VIRTUEMART_PASS1') . " : " . $this->user['pass1'] . "<br />";
   echo $this->phone. "<br />";
   echo $this->object. "<br />";
   echo $this->size. "<br />";
   echo $this->glass. "<br />";
   echo $this->pass. "<br />";
   echo $this->pass1. "<br />";
   echo $this->comment. "<br />";
  ?>


I'm using joomla version 2.5.20, and virtuemart version 2.0.26d

What I am doing wrong?
Thank you for your attention.

GJC Web Design

You can't have all these multiple form elements - one opening with an action etc and one closing

surround all inputs with them
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Hugu

Hi GJC Web Design!

Thank you for your attention and for your quick reply.

So, if I understood what you said, I can't use those 3 form actions. I used just one, surrounding the combo box fields, but I'm still getting the error :(

GJC Web Design

one form on the form.php
just add the extra inputs in it
google a html form tutorial
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Hugu

Thank you once again for you answer GJC Web Design!

I found the reason why it wasn't working. I had a </form> in the middle of the code I forgot to remove. I removed it and now is working fine!

Thank you for your attention!  ;D

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation