/** * Test if there are two picklist values with the same name. This is not allowed. */ public function validateContactStatesData($attribute, $params) { $data = $this->{$attribute}; if (array_diff_key($data, array_unique($data))) { $this->addError('contactStatesData', Zurmo::t('ContactsModule', 'Each ContactsModuleSingularLowerCaseLabel state must be uniquely named', LabelUtil::getTranslationParamsForAllModules())); } foreach ($data as $order => $name) { $contactState = new ContactState(); $contactState->name = $name; $contactState->order = $order; if (!$contactState->validate()) { foreach ($contactState->getErrors() as $attributeName => $errors) { if ($attributeName == 'name') { foreach ($errors as $error) { $this->addError('contactStatesData', $error); } } } } } //todo: validate against contactState rules as well. like minimum length = 3 }