Buy Now
Sign in

Pass Variable from Virtuemart to Chronoform Field

nicobond , February 25 2016, 10:53
nicobond 10
February 25 2016, 10:53 #357039
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');
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?
GreyHead 64
February 25 2016, 11:56 #357041
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.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
nicobond 10
February 25 2016, 14:04 #357044
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;
$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