Forums

Pass Variable from Virtuemart to Chronoform Field

nicobond 25 Feb, 2016
Hi, i've a request.
I'm using joomla+virtuemart on a travel site.
In Product details i've included a chronoforms form, with
$module = JModuleHelper::getModule('mod_custom','Richiestadisponibilita');
$nome_prodotto=this->product->product_name;
echo JModuleHelper::renderModule($module);

The form is in a html custom module, but i think was the only solution to render it where i want on the product detail page.

There is a field called "Struttura/Alloggio" (in italian) and it means the name of the hotel or residence etc.
The name is a variable in the page (php file where i render the module) called "this->product->product_name".

I want to pass this variable to an hidden field, so the user have not to write the name of the hotel everytime.
How can i do this?
Thanks.
GreyHead 25 Feb, 2016
Hi nicobond,

I have no idea how the form will work when you you load it that way. Does VirtueMart not support content plug-ins?

Usually you can use JavaScript to pick up a VirtueMart identifier either from the page URL; or the menu item; or from an HTML element in the page.

Bob
nicobond 25 Feb, 2016
1 Likes
Hi GreyHead, thank you for the reply.
However, i'm so happy because i've solved it by myself!
In the .php file that generate product detail, i put this code:


global $nome_prodotto;
$nome_prodotto=$this->product->product_name;

jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_custom','Richiestadisponibilita');
echo JModuleHelper::renderModule($module);

I defined $nome_prodotto as a global variable, and then, in custom code that generate the form in chronoform, i put this code to take the variable and put in the hidden field:

<input name="nome_prodotto" id="nome_prodotto" value="<?php echo $GLOBALS["nome_prodotto"] ?>" type="hidden" class="form-control A" />

Whit Global Variables you can do many many things like pass "distant" variable.
I think this can be useful for someone🙂
This topic is locked and no more replies can be posted.