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);
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | barcodes.patch | 1.3 KB | jastraat |
| patronselect.patch | 945 bytes | grahl |
Comments
Comment #1
jastraat commentedThe 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
Comment #2
jastraat commentedNew patch
Comment #3
jastraat commentedCommitted to latest dev release
Comment #4
grahlHi,
thank you for improving this patch! I hadn't had time to test it until now but it works flawlessly.