I am trying to set an "Approved By" and "Approved Date" field on my form when the user changes the status to "Approved".
I am doing this in the form's PHP code on form submission page. I selected "Start of form submission (onBeforeProcess)".
My code is:
$user =& JFactory::getUser();
$username = $user->get('username');
$approved = $formModel->formData['access_mgmt___approval'];
/*if ($approved == 'Approved' && $formModel->formData['access_mgmt___approved_by'] == '') {*/
if ($approved == 'Approved')
$date = date('m/d/Y');
/*$formModel->updateFormData('access_mgmt___approved_by', $username, true);*/
$formModel->updateFormData('access_mgmt___approved_by', $approved, true);
$formModel->updateFormData('access_mgmt___approve_date', $date, true);
}
The code comparison $approved == 'Approved' won't return true, however when I remove that comparison and always execute the code, I set the field to $approved and it does indeed equal "Approved".
Is the $approved value not recognized yet when this code is executed? That is all I can think of, any help is appreciated.
I am doing this in the form's PHP code on form submission page. I selected "Start of form submission (onBeforeProcess)".
My code is:
$user =& JFactory::getUser();
$username = $user->get('username');
$approved = $formModel->formData['access_mgmt___approval'];
/*if ($approved == 'Approved' && $formModel->formData['access_mgmt___approved_by'] == '') {*/
if ($approved == 'Approved')
$date = date('m/d/Y');
/*$formModel->updateFormData('access_mgmt___approved_by', $username, true);*/
$formModel->updateFormData('access_mgmt___approved_by', $approved, true);
$formModel->updateFormData('access_mgmt___approve_date', $date, true);
}
The code comparison $approved == 'Approved' won't return true, however when I remove that comparison and always execute the code, I set the field to $approved and it does indeed equal "Approved".
Is the $approved value not recognized yet when this code is executed? That is all I can think of, any help is appreciated.