Adding Joomla Article *Title* to Form Submission results

john.murray 19 Mar, 2013
I've seen this topic discussed in other threads, and have tried the code supplied in one with unsuccesful results:

currently running 4.0 RC3.5.2

an example of this form can be found at

http://baydosrvs.com/motor-homes/75-2006-tioga-sl-31w-class-c

this is found in the code tab under forms manager:

<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
$title = '';
if ( $article_id ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT `title`
      FROM `#__content`
      WHERE `id` = ".$db->quote($article_id)." ;
  ";
  $db->setQuery($query);
  $title = $db->loadResult();
}
?>
<input type='hidden' name='title' id='title' value='<?php echo $title; ?>' />

<div class="ccms_form_element cfdiv_text" id="name1_container_div" style=""><label>Name</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="name" />
<div class="clear"></div><div id="error-message-name"></div></div><div class="ccms_form_element cfdiv_text" id="phone1_container_div" style=""><label>Phone</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="phone" />
<div class="clear"></div><div id="error-message-phone"></div></div><div class="ccms_form_element cfdiv_text" id="email1_container_div" style=""><label>Email</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="email" />
<div class="clear"></div><div id="error-message-email"></div></div><div class="ccms_form_element cfdiv_textarea" id="notes1_container_div" style=""><label>Notes</label><textarea cols="45" rows="12" class="" title="" name="notes"></textarea>
<div class="clear"></div><div id="error-message-notes"></div></div><div class="ccms_form_element cfdiv_submit" id="input_submit_51_container_div" style="text-align:left"><input name="input_submit_5" class="" value="Submit" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_5"></div></div>


the emailed result show:

getTitle(); ?>' />
Name John Murray
Phone 11111111
Email [email]john@domain.blah[/email]
Notes test
Submitted by 204.16.41.114
GreyHead 20 Mar, 2013
Hi John,

The code you have was for the older version of ChronoForms but appears to be working OK as I can see this in the Form HTML on the page you linked to:
<input id="title" type="hidden" value="2006 Tioga SL 31W, Class C" name="title">

Also the 'getTitle();' doesn't appear in the code you posted so that must be coming from somewhere else. Do you have any code in the On Submit event of your form that is also trying to set the title?

Bob
john.murray 20 Mar, 2013
thanks for the quick response! Your correct, I did have some previous code in onsubmit()- I just went ahead and recreated the form from scratch. What seemed to do the trick was manually adding the php "title" variable to the form results:


<table border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td><strong>Model</strong></td>
<td>{title}</td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td>{name}</td>
</tr>
<tr>
<td><strong>Phone</strong></td>
<td>{phone}</td>
</tr>
<tr>
<td><strong>E-Mail</strong></td>
<td>{e-mail}</td>
</tr>
<tr>
<td><strong>Notes</strong></td>
<td>{notes}</td>
</tr>
</tbody>
</table>
This topic is locked and no more replies can be posted.