Calc in repeated group causes corrupt form display.

bggann

Active Member
I've got a form with repeated groups.
In the repeated groups are calc element that depends on the data in that group as well as the parent group.
All works well till I hit repeated group 6 (in other words I can have 5 repeated groups).
On the 6th group, if I trigger a calculation (ajax), the calculated group display appears briefly but then is overwritten with a view of the home page of the site.

In other words, where the calculated element should be displayed, you see the front page of the site.
The error is systematic. I use the same calculation in up to 4 fields in the repeated group (I do not use the results of one calc in another calc, I repeat the base calculation). All of those fields are replaced with the "home page" display.

If I ignore the corrupt display, and submit the record, it actually writes to the database correctly, so this appears to be something related to ajax (maybe?) or an overflow (maybe?).

Here is the code that is in the calc element.
I've attached a couple screen shots - one showing the correct display, the other showing the corrupt display.

Looks like some kind of overflow????
------------
//Code for picking Rate
// Duplicating calculation of time here to force calculation
//dumpmessage('Start flight seat cost');
$db = JFactory::getDbo();
$start_time = explode(",",'{daily_log_7_repeat___seat_start_time_raw}');
if ( empty($start_time[1])) {$start_time[1]="00";}
if ( empty($start_time[0])) {$start_time[0]="00";}
$start_time_text = implode(':',$start_time);
$start_time_sec = strtotime('01/01/1980 '.$start_time_text.':00');
//dump($start_time_sec,'start_time_sec');
$stop_time = explode(",",'{daily_log_7_repeat___seat_stop_time_raw}');
if ( empty($stop_time[1])) {$stop_time[1]="00";}
if ( empty($stop_time[0])) {$stop_time[0]="00";}
$stop_time_text = implode(':',$stop_time);
$stop_time_sec = strtotime('01/01/1980 '.$stop_time_text.':00');
//dump($stop_time_sec,'stop_time_sec');
if ($stop_time_sec < $start_time_sec) {
$stop_time_sec += 86400;
}

$flight_hours_raw = (float)($stop_time_sec - $start_time_sec)/3600 ;
$flight_hours = round ( $flight_hours_raw,2);
//dump($flight_hours,'flight hours');

$n_number = '{daily_log___aircraft_n_number_raw}';

if (empty($n_number) or empty($flight_hours)) {
//dumpmessage('Exiting flight cost');
// Exit out
}
else {
$query_string = 'SELECT aircraft_base_flight_rate FROM aircraft WHERE id = "'.$n_number.'"';
//dump($query_string,'Query');
$db->setQuery($query_string);
$rows = $db->loadObjectList();
//dump($rows,'rows');
foreach ($rows as $row) {
$rate = $row->aircraft_base_flight_rate;
}
}
$total_cost = (float) $rate * $flight_hours;
//dump($total_cost,'total cost');
//dump($flight_hours,'flight hours');
//dump($rate,'rate');
//dumpmessage('end seat flight cost');
return $total_cost;
-------------
This is correct. Seat Flight Start Time triggers calculation of Seat Flight Time and SEAT flight cost.
This is as loaded from the database.
correct.JPG
This is the corrupted one. This happens after ajax
Notice how the calc feilds have be replaced with the site front page
corrupt.JPG
 
Further information
If I turn off AJAX on the problem feilds, the issue does not appear. Is this an ajax overflow problem?
 
I suspect it's probably something like max_input_vars, if you have a lot of elements in your repeat.

Try doubling it in your PHP ini.

-- hugh
 
Yep - you are right - I ran into this problem before - oh fickle memory. Increased max variables in php.ini and it resolved.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top