Where _ is the id number I used.

In my particular case I entered the following badge by using autocompletion:
Proscrit (Badge ID 12)

I tried id's from 1 to 15 but it didn't work either. Maybe if I could check what is the id somehow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mermemladeK’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Still getting the same problem after installing 7.x-2.x-dev.
Any updates on this issue?

This is an example of error message:
14 is not a valid badge ID. Try using the autocomplete function (requires javascript).
(I used autocomplete)

mermemladeK’s picture

Status: Active » Closed (fixed)

It got solved, not sure how, but I guess after cleaning badges, images, completely uninstalling it and restalling lates dev it worked. Or maybe it was another module, who knows now...

kewalk’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

I would like to repeat..1 am getting the same error as above

shabana.navas’s picture

A fix for this will be submitted very shortly.

kewalk’s picture

Thank you. However, this module is quite slow on its track of development, especially regarding issues such as those mentioned above. It is to note that this issue has been around for a long long time. I understand that the maintainers are busy but may be a little attention can help. Once again, we are thankful for this wonderful module, but its testing our patience. I for example, made do, with flags as badges. Not correct or elegant, but it worked. Just waiting for this module to function at least the minimum functionality and then would use it.

mermemladeK’s picture

That's great Shabana!

Kewalk: while I agree on what you say, I don't think you should blame it on Shabana because I think he's just new blood in this project and so far providing patches and apparently even an update.

kewalk’s picture

@mermemladeK...i do not blame any one...it just that its a tad slow...and as i said earlier i understand the time concerns but this being a module which has great potential is lacking behind...once again i am thankful for the module...waiting for it being functional...i am glad to assist in any way whatsoever...

indyana’s picture

For anyone still seeing this, could you provide more details on the Badges settings used or the environment? I just installed the 7.x-2.x-dev module, planning to troubleshoot, but I'm unable to replicate it.

indyana’s picture

Still not able to replicate this, but I did notice something while going through the code. To determine if the badge ID is valid, we do a db_select matching the id to the "bid" field in table user_badges_badges, then perform a rowCount on the results. Documentation indicates that this is not the preferred method of determining the results of a SELECT operation. rowCount may not return the actual result count on some database systems and can only reliably be used for DELETE, INSERT, or UPDATE queries.

See:
http://drupal.org/node/1251174
"To count the number of rows returned from a SELECT statement use"

indyana’s picture

Status: Active » Needs review
FileSize
867 bytes

Here's a patch that reflects the change mentioned above.

Added ->countQuery() before executing the query to change it into a count query, then changed rowCount to ->fetchField() to get the count result.

This works exactly the same way in my local installation. I'm hopeful it might solve this issue for some folks, but, as I haven't been able to replicate this, I cannot be certain. Please comment with your results if you try this patch.

Reached a deadend here. Other information that could be helpful for context would be Drupal core version, PHP version, and database version. If you're comfortable with looking in the database tables, you could also take a peek in table user_badges_badges to see if the specified ID ("bid") is correct.

indyana’s picture

Assigned: Unassigned » indyana
shabana.navas’s picture

Status: Needs review » Closed (fixed)
gaguime’s picture

Title: When assigning a badge to a role it outputs the following error "_ is not a valid badge ID." » When assigning a badge to a role or a user it outputs the following error "_ "un" is not a valid badge. Try using the autocomple
Version: 7.x-2.x-dev » 7.x-3.x-dev

I have applied the patch but it doesn't help. My site is in english

shabana.navas’s picture

Title: When assigning a badge to a role or a user it outputs the following error "_ "un" is not a valid badge. Try using the autocomple » When assigning a badge to a role or a user it outputs the error '" " is not a valid badge. Try using the autocomplete'
Status: Closed (fixed) » Needs review
shabana.navas’s picture

Status: Needs review » Postponed (maintainer needs more info)

Please provide your exact steps for replicating this issue as I haven't been able to duplicate the error.

gaguime’s picture

FileSize
111.94 KB

I have created four badges. when I try to assign them to either
a role: http://dentalhealthdubai.com/commons/admin/config/people/user_badges/roles
an user: http://dentalhealthdubai.com/commons/user/1/edit/badges

I get the message: "un" is not a valid badge. Try using the autocomplete function (requires javascript).
You can find the

I am kind of knew here and I don't know why autocomplete is not activated though

thanks

shabana.navas’s picture

Have had some issues to take care of the last few days, will take a look at this as soon as I get some time.

shabana.navas’s picture

I have added the same badges and still not getting any errors when I try to assign a badge to a role or user. This might be obvious, but, do you have javascript enabled in your browser? Make sure you also clear cache, just in case. I don't think you really need this patch anyway as it doesn't do anything fundamentally different. There must be some other problem.

Can you check the user_badges_badges table and report back what records you have there?

wikibi’s picture

Ok, I FINALLY figured it out. The "read me" text should explain more thoroughly how to do this. Wanted to use this wonderful module in drupal 6 (had same problem) finally now able to use for drupal 7. Blah, blah let me get to the point.

1- Go to admin/config/people/user_badges press "add new badge" and submit a URL to your badge or upload.
2- The badge will appear under "List."
3- Now this is the fun part - Under the "Name" column copy the badge name.
This will allow you to use autocomplete function in the next step!
AND HERE I WAS THINKING HOW TO KICK IN THE AUTOCOMPLETE??
4- Click on the "roles" link and "paste" the badge name. The autocomplete will show you the badge.
Solved!
Would be great to have this module work with userpoints.

shabana.navas’s picture

So, are you saying you just had the problem of not being able to select the badge name via the autocomplete? Is this issue just a pure case of not using the autocomplete when entering a badge?

Basically, the autocomplete puts the badge id at the end, and, I think perhaps, people just paste in the badge name before the autocomplete could kick in and the badge id, which should be there at the end, is left out, giving you the error.

I guess if that is the problem, I can just add a description underneath the textfield to let users know that they need to wait for the autocomplete to load.