applyFilter('__ALL__', 'trim'); if ( !$inlineEditMode || $inlineEditMode == 1 ) { // Organization_name $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name']); } if ( !$inlineEditMode || $inlineEditMode == 2 ) { // legal_name $form->addElement('text', 'legal_name', ts('Legal Name'), $attributes['legal_name']); // nick_name $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name') ); // sic_code $form->addElement('text', 'sic_code', ts('SIC Code'), $attributes['sic_code']); $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); } if ( !$inlineEditMode ) { $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier') ); } } static function formRule($fields, $files, $contactID = NULL) { $errors = array(); $primaryID = CRM_Contact_Form_Contact::formRule($fields, $errors, $contactID); // make sure that organization name is set if (empty($fields['organization_name'])) { $errors['organization_name'] = 'Organization Name should be set.'; } //check for duplicate - dedupe rules CRM_Contact_Form_Contact::checkDuplicateContacts($fields, $errors, $contactID, 'Organization'); // add code to make sure that the uniqueness criteria is satisfied return empty($errors) ? TRUE : $errors; } }