chris.paschen
Chris Paschen
I have a repeating group where I need to change the value of several elements (setting a date field to the current or future date) based on the previous and current values of certain fields within the same repeating group item.
So basically:
if $newStatus is X and $origStatus is Y set the date
do that for several different status elements and date elements
repeat over the entire repeat group for this present main entry.
I presently have this for the process that needs to happen (which works properly for the first item in the repeating group):
I've reviewed the suggestions here:
http://fabrikar.com/forums/index.ph...-a-field-in-a-repeat-group.43315/#post-221171
However, I'm not sure what the proper syntax would be to get the $origData for each item.
Can you help 'translate' how to access those getOrigData lines so that they properly pull in the data for the repeating group?
NOTE: This is running on the onBeforeStore of the form.
So basically:
if $newStatus is X and $origStatus is Y set the date
do that for several different status elements and date elements
repeat over the entire repeat group for this present main entry.
I presently have this for the process that needs to happen (which works properly for the first item in the repeating group):
PHP:
$reviewType = $formModel->formData['ked_books_reviews_requests_49_repeat___type_raw'];
$origData = $formModel->getOrigData();
$origData = FArrayHelper::getValue($origData,0,new stdClass);
$origStatus = $origData->ked_books_reviews_requests_49_repeat___status_raw;
$origStatus = is_array($origStatus) ? $origStatus[0] : $origStatus;
$newStatus = $formModel->formData['ked_books_reviews_requests_49_repeat___status_raw'];
switch ($newStatus)
{
case "2": //assigned
if ($origStatus == 1) //was waiting for assignment
{
//set the response by date
$now = new DateTime();
//set the date assigned
$formModel->formData['ked_books_reviews_requests_49_repeat___date_assigned'] = $now->format('Y-m-d H:i:s');
//get the number of days to respond
$db = JFactory::getDbo();
$query = $db->getQuery(true);
if ($reviewType == 2) {
$query->select('review_decline_timelimit');
} else {
$query->select('review_decline_timelimit');
}
$query->from($db->quoteName('ked_books_system_settings'));
$query->where("1");
$db->setQuery($query);
$hoursToRespond = (int)$db->loadResult();
$responseDue = $now->modify('+'.$hoursToRespond.' hours');
$formModel->formData['ked_books_reviews_requests_49_repeat___date_request_due'] = $now->format('Y-m-d H:i:s');
}
break;
case "7": //review published
if (!($origStatus == 7))
{
//set the published date
$now = new DateTime();
//set the date published
$formModel->formData['ked_books_reviews_requests_49_repeat___date_published'] = $now->format('Y-m-d H:i:s');
}
break;
}
I've reviewed the suggestions here:
http://fabrikar.com/forums/index.ph...-a-field-in-a-repeat-group.43315/#post-221171
However, I'm not sure what the proper syntax would be to get the $origData for each item.
Can you help 'translate' how to access those getOrigData lines so that they properly pull in the data for the repeating group?
NOTE: This is running on the onBeforeStore of the form.