How to get product name from one of the static pages to the form

serguei_kp 24 Dec, 2020
Hello Chronoform, Merry Christmas!
I need your help to get product name from a static page to the form.
Lets consider next scenario:
I've got several product pages A, B, C and I have one form F, this form is published (shared) via module on each product page.
Is it possible, when page C is loaded to get product name of page C into the form and so on,
if page B is loaded get product name B to the form?

In other words, I would like to have one form for several static html pages (no database queries), and get the data from the page to the form, when this page is loaded.


Best regards.
GreyHead 28 Dec, 2020
Hi serguei_kp,

ChronoForms adds the variables from the page URL into the form data when the form is loaded. If you temporarily add a debugger action to the Form Load event you can see the data. You can then use this to set the value of a hidden input in the form which will identify the page when the form is submitted.

Bob
serguei_kp 28 Dec, 2020
Answer
Hello Bob, thank you!

I found the solution, I put the values (product name and product type) in alias and note field of an article, and then retrieve it with PHP code.

Just add : {var:default_service_name_php} or {var:default_service_type_php}
in the field Value of each feild where you need to load default value.

PHP code:
Name: default_service_name_php
$article_title = '';
$id = JRequest::getInt('id');
$article =& JTable::getInstance('content');
$article->load($id);$article_alias = $article->get('alias');
return $article_alias;

PHP code:
Name: default_service_type_php
$article_title = '';
$id = JRequest::getInt('id');
$article =& JTable::getInstance('content');
$article->load($id);
$article_note= $article->get('note');
return $article_note;
You need to login to be able to post a reply.