4
class iHRIS_Module_Trainer extends I2CE_Module {
9
* Return the array of hooks available in this module.
12
public static function getHooks() {
14
'validate_form_trainer' => 'validate_form_trainer',
19
* Perform extra validation for the trainer form.
20
* A new trainer record needs to verify there aren't any existing
21
* records with the same name.
22
* @param I2CE_Form $form
24
public function validate_form_trainer( $form ) {
27
$surname_ignore = false;
28
if ( isset( $form->surname_ignore ) ) {
29
$surname_ignore = $form->surname_ignore;
31
if ( I2CE_ModuleFactory::instance()->isEnabled('forms-storage')
32
&& $form->getId() == 0 && !$surname_ignore
33
&& I2CE_Validate::checkString( $form->surname )
34
&& I2CE_Validate::checkString( $form->firstname ) ) {
39
'operator'=>'FIELD_LIMIT',
41
'style'=>'lowerequals',
42
'data'=>array('value'=>strtolower($form->surname))
45
'operator'=>'FIELD_LIMIT',
47
'style'=>'lowerequals',
48
'data'=>array('value'=>strtolower($form->firstname))
52
$results = I2CE_FormStorage::listFields('trainer',array('surname','firstname'),false,$where,array('surname','firstname'));
53
if( count($results) > 0 ) {
54
foreach ($results as $id=>&$data) {
55
$data = implode(', ', $data);
57
$form->getField('surname')->setInvalid( "Duplicate records match this record's name:",
58
array( "viewtrainer?id=" => $results ) );
70
# c-default-style: "bsd"
71
# indent-tabs-mode: nil