When checking an item out, the autocomplete field searches through the title field with LIKE %s%%, that allows to search from the beginning but not inline (as is useful when searching for a title that contains first and last name), the substitution pattern %%%s%% will do the trick.

I also added the further functionality of being able to also search the patron barcode numbers.

What I wasn't able to do was display the card number, next to the name, in the dropdown list and still have the form work, suggestions for that would be very much appreciated. I had tried something like this, but that proved to be a bad idea:

$matches[$patron->title .' [Card number:'. $patron->barcode .']'] = check_plain($patron->title);

CommentFileSizeAuthor
#2 barcodes.patch1.3 KBjastraat
patronselect.patch945 bytesgrahl

Comments

jastraat’s picture

The library module, like the CCK nodereference module, uses preg_match() to locate the nid in an autocomplete string. The nid is located in brackets and is required to be part of the string within brackets for the form to validate.

I've attached a modified version of your patch for you to try out that adds barcodes to the autocomplete results as you type. (The library module also uses the title in the submitted form value for validation, so barcode can't be included in the end form value).

If this works for you, I can commit it to CVS.
Thanks,
Jess

jastraat’s picture

StatusFileSize
new1.3 KB

New patch

jastraat’s picture

Status: Needs review » Fixed

Committed to latest dev release

grahl’s picture

Hi,
thank you for improving this patch! I hadn't had time to test it until now but it works flawlessly.

Status: Fixed » Closed (fixed)

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