Author Topic: Add fields (Company name, Telephone number) in Ask Question form not working  (Read 470 times)


  • Beginner
  • *
  • Posts: 8
  • A beginner

First of all, I'm using the latest Joomla (3.8.1) and Virtuemart version (3.2.4).
Previously, I manually added two fields (Company name and Telephone number) to the Ask Question form which worked perfectly. However, since the update to the latest version of Virtuemart this does not work anymore. I get the following errors:

Notice:  Undefined property: Joomla\CMS\User\User::$companyname in <b>C:\...\components\com_virtuemart\views\askquestion\tmpl\form.php</b> on line <b>76</b><br /><br /><b>Notice</b>:  Undefined variable: askQuestionData in C:\...\components\com_virtuemart\views\askquestion\tmpl\form.php on line 76

<br /><b>Notice</b>:  Undefined property: Joomla\CMS\User\User::$phone in <b>C:\...\components\com_virtuemart\views\askquestion\tmpl\form.php</b> on line <b>88</b><br /><br /><b>Notice</b>:  Undefined variable: askQuestionData in <b>C:\...\components\com_virtuemart\views\askquestion\tmpl\form.php</b> on line <b>88</b><br />

Below is the code that always worked, up until now.

Code: [Select]
<table class="askform">
<td><label for="companyname"><?php echo vmText::_('COM_VIRTUEMART_ASKQUESTION_COMPANYNAME')  ?> : </label></td>
<td><input type="text" class="validate[required,minSize[2],maxSize[64]]" value="<?php echo $this->user->companyname $this->user->companyname $askQuestionData['companyname'?>" name="companyname" id="companyname" size="30"  validation="required companyname"/></td>
<td><label for="name"><?php echo vmText::_('COM_VIRTUEMART_USER_FORM_NAME')  ?> : </label></td>
<td><input type="text" class="validate[required,minSize[3],maxSize[64]]" value="<?php echo $this->user->name $this->user->name $sessData['name'?>" name="name" id="name" size="30"  validation="required name"/></td>
<td><label for="email"><?php echo vmText::_('COM_VIRTUEMART_USER_FORM_EMAIL')  ?> : </label></td>
<td><input type="text" class="validate[required,custom[email]]" value="<?php echo $this->user->email $this->user->email $sessData['email'?>" name="email" id="email" size="30"  validation="required email"/></td>
<td><label for="phone"><?php echo vmText::_('COM_VIRTUEMART_ASKQUESTION_PHONE')  ?> : </label></td>
<td><input type="text" class="validate[required,minSize[8],maxSize[18]]" value="<?php echo $this->user->phone $this->user->phone $askQuestionData['phone'?>" name="phone" id="phone" size="30"  validation="required phone"/></td>
<td colspan="2"><label for="comment"><?php echo vmText::sprintf('COM_VIRTUEMART_ASK_COMMENT'$min$max); ?></label></td>
<td colspan="2"><textarea title="<?php echo vmText::sprintf('COM_VIRTUEMART_ASK_COMMENT'$min$max?>" class="validate[required,minSize[<?php echo $min ?>],maxSize[<?php echo $max ?>]] field" id="comment" name="comment" rows="8"><?php echo $sessData['comment'?></textarea></td>

Any ideas on how to fix this?

Thanks in advance!

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3137
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
$this->user->companyname for eg do not exist.
Simply try to replace
$this->user->companyname ? $this->user->companyname : $askQuestionData['companyname']
Of course if $askQuestionData['companyname'] exist.
Else you need to use Joomla sessions or no data at all.
But i'm not sure that this get send in the mail from your form, because Vm do not check this.