Forums

Adding extra data to the form data

eglescout 04 May, 2011
Hello,

I have a form where I need to calculate a price and pass it into emails and into the database table. I'm using Joomla 1.5.

In ChronoForms v3.x, this worked:

  //Calculate total amount to charge card
  $amount = 12.00;
  $tickets = JRequest::getString('tickets','', 'post');
  $totalcost = $tickets * $amount;
  JRequest::setVar('totalcost', $totalcost);


Should I be doing something different for ChronoForms v4? I haven't gotten the JRequest line to work.

I'd like to make some custom subject fields for email messages. Will the JRequest work, or do I need to do something different?

...and while I'm at it, would the solution change if I were in Joomla 1.6? We are planning on migrating this site in a few months, so I'll need to know how make this work in Joomla 1.6.

Thanks!
GreyHead 04 May, 2011
Hi eglescout,

Yes Max has changed the way that form data is handled in CFv4. Instead of
JRequest::setVar('totalcost', $totalcost);
I think you need
$form->data['totalcost'] = $totalcost;

Bob

PS ChronoForms v4 is pretty much the same for Joomla! 1.5 & 1.6 so that upgrade path should be straightforward.
eglescout 06 May, 2011
Thanks GreyHead. That worked perfectly!

Because the data is stored/handled differently in v4, should I be using something different than the following to get data out of the form?


$tickets = JRequest::getString('tickets','', 'post');


This is working. I'm just wondering if there's a better way to do this that might make this translate better into Joomla 1.6 or future releases of ChronoForms.

Thanks!
GreyHead 06 May, 2011
Hi eglescout,

Yhe JRequest methods are Joomla! code (rather than ChronoForms code) and are unchanged. They also exist and work the same way in Joomla! 1.6.

About 98%, maybe more, of the code will work in Joomla! 1.6. They are only a few changes that are important for ChronoForms.


Bob
This topic is locked and no more replies can be posted.