When trying to alter the badges I get the following message:
"Admin (Badge ID 1)" is not a valid badge name. Try using the autocomplete function (requires javascript).

I've tried all kind of combinations, but it doesn't except the badge-role assignment. I've tried to use the autocomplete function, to use "Admin", "Badge ID 1" but nothing seems to work... anyone who has the same problem? It's a clean install...


Is it just me having this issue?

I have added badges.

Version:6.x-1.6» 6.x-1.x-dev

If no one else has this problem... any idea what may produce such error?
I'm barely using custom code and mostly use well known modules... so there has to be some kind of incomparability somewhere.

Are you seeing any errors in dblog or Apache?

No, only the errors on the actual page...

Is #947172: Private download setting the problem? Otherwise, try the most recent -dev version and see if it works now.

Priority:Major» Critical

NancyDru: No

Besides, this is still an issue in the latest dev, this is critical in order to make use of the module...
Image: http://i.imgur.com/JZk0F.png

This error is being thrown due to this code returning false:

if (preg_match('/\('. t('Badge ID') .' (\d+)\)/', $value, $matches)) {

where $value is the value from the autocomplete field. Since "Badge ID" is the expression it's trying to match, it makes me wonder if there's some way Badge ID is being translated that is causing the match to fail? I noticed that your site has some non-English text in it, which is why I'm suspecting that it's a translating issue. If you have translated the string "Badge ID" somewhere, maybe it needs to be reverted? Or vice-versa, perhaps the string needs to be translated?

That's my best guess but hopefully this will point you in the right direction.

Status:Active» Fixed

Wow, you are right! I've tried a lot of things today, but I would never have guessed that to be the problem (since it's wrapped inside the t()).

Thanks, this fixed at least my problem, but maybe the string should not be translatable in the first place then? :)

Priority:Critical» Major
Status:Fixed» Active

When I looked at your image, I wondered the same thing. Glad you verified that problem.

I know that if I removed the t() function, someone else would scream for it to be put back. I'll have to look at the code when I get home and see if the autocomplete is not using t().

Another possibility is to just not show the "Badge ID" stuff at all - just the badge name. That could be a performance improvement because preg_match is not very fast.

+1 for the solution in #10 "not show the Badge ID". I would perhaps do it the same way the autocomplete nodereference field works, that is Title followed by "[nid: 1234]". That way if you need to, you can extract the nid (or in this case, bid) and not worry about having to translate a string.

EDIT: I think I found the issue, as you suspected it looks like the value being returned by autocomplete is not actually translating the right string:

function user_badges_badge_autocomplete($string = '') {
$matches = array();
  if (
preg_match('/^[^(]+/', $string, $searchstring)) {
$trimstring = trim($searchstring[0]);
$result = db_query_range("SELECT * FROM {user_badges_badges} WHERE name LIKE '%%%s%%'", $trimstring, 0, 10);
    while (
$badge = db_fetch_object($result)) {
$matches[$badge->name . ' ' . t('(Badge ID') . ' ' . $badge->bid .')'] = check_plain($badge->name) . ' ' . theme('user_badge', $badge);

The string wrapped in t() is "(Badge ID" and it should actually be just "Badge ID". The parentheses should be moved to the outside, I think, so that it's just the text without punctuation, which is what preg_match is searching for:

if (preg_match('/\('. t('Badge ID') .' (\d+)\)/', $value, $matches)) {

I would provide a patch but it's an easy fix, and also, I'm just looking at the source code in the CVS repo... I don't actually use this module yet. :)

That would do it. Thanks for checking. I'm dealing with RealLife™ right now.

Status:Active» Fixed

Committed to 6.x-1.x-dev.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

A bad news as i've update user-badges to latest 6.x-1.x-dev, I still got error message when i try to assign badge to a user

"Player" is not a valid badge. Try using the autocomplete function (requires javascript).

"1" is not a valid badge. Try using the autocomplete function (requires javascript).

how can I help to figure out the problem ?

Status:Active» Closed (fixed)

kind of amazing~ it works fine after my lunch ...

It was a good lunch then. Is it possible that the caches got cleared or something like that?

Actually, I've clean cache data before my lunch and taken a test, but it still failed. Then I went for lunch and after that it goes fine...

Wierd. It's hard to fix something that goes away mysteriously. Do you have an op-code cache that maybe took some time to update?