/** * Test if there are two picklist values with the same name. This is not allowed. Also make sure there is * no comma in the value string. */ public function validateCustomFieldDataData($attribute, $params) { $data = $this->{$attribute}; if (!empty($data) && ($nonUniqueData = array_diff_key($data, ArrayUtil::array_iunique($data)))) { $nonUniqueValuesString = null; foreach ($nonUniqueData as $nonUniqueValue) { if ($nonUniqueValuesString != null) { $nonUniqueValuesString .= ', '; } $nonUniqueValuesString .= $nonUniqueValue; } $this->addError('customFieldDataData', Zurmo::t('DesignerModule', 'Each item must be uniquely named and the following are not: {values}', array('{values}' => $nonUniqueValuesString))); } if (!empty($data)) { foreach ($data as $value) { if ($value != str_replace(',', '', $value)) { $this->addError('customFieldDataData', Zurmo::t('DesignerModule', 'Each value must not contain a comma.')); return; } elseif ($value == '') { $this->addError('customFieldDataData', Zurmo::t('DesignerModule', 'Value cannot be blank.')); return; } } } }