Reputation: 379
I'm trying to get the page title inside my form so i can know from witch page the form was submitted.
I have seen RS Form's tutorial here -> http://www.rsjoomla.com/support/documentation/view-article/369-get-the-page-title.html
This doesn't seem to work. what i was trying to do is creating a hidden filed and inserting his default value to following code:
<?php
$doc = JFactory::getDocument();
return $doc->getTitle();
?>
Afterwards, i added the hidden field to the form layout and useradmin by the quick toggle of RS Form Options.
What i get in the email received is only this: getTitle(); ?> and not the true pagetitle.
Have i gone wrong somewhere? and if so - where? maybe there is another way to do that?
Upvotes: 2
Views: 1166
Reputation: 2767
From reading the RS Form instructions, it sounds like you should use //<code>
instead of <?php
ie
//<code>
$doc = JFactory::getDocument();
return $doc->getTitle();
//</code>
I assume anything within those tags is then filtered before the form is displayed so that it renders as php.
From your email response, it looks like it renders raw php as text.
Upvotes: 1
Reputation: 647
How about getting the URL of the page, instead of the title. The advantage is that it's unique (pages can have duplicated titles). This PHP code in a hidden field did the trick for me in BreezingForms, I assume it'll work in RS Form too:
<?php $pageURL = 'http://'; $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; return $pageURL ?>
Upvotes: 1