Add fields (Company name, Telephone number) in Ask Question form not working

Started by pvlooy, October 06, 2017, 17:00:36 PM

Previous topic - Next topic

pvlooy

Hi,

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.

<table class="askform">
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<td colspan="2"><label for="comment"><?php echo vmText::sprintf('COM_VIRTUEMART_ASK_COMMENT'$min$max); ?></label></td>
</tr>
<tr>
<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>
</tr>
</table>


Any ideas on how to fix this?

Thanks in advance!

Studio 42

$this->user->companyname for eg do not exist.
Simply try to replace
$this->user->companyname ? $this->user->companyname : $askQuestionData['companyname']
by
$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.