Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.1

Bug #14031 Detach element id and remote callback name
Submitted: 2008-05-30 12:45 UTC
From: shangxiao Assigned: thesee
Status: Assigned Package: HTML_QuickForm_Livesearch (version 0.4.0)
PHP Version: 5.2.6 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2008-05-30 12:45 UTC] shangxiao (David Sanders)
Description: ------------ When I first saw that the callbacks had to be the same name as the element id, I thought it was a bit strange, but just left it as is. Now I see a problem with this design. Quite often database designs will have multiple foreign keys referencing the same table. When using formbuilder to represent this table and livesearch as the field type to search the foreign table (needing to search all in exactly the same way), then this shows the limitation of livesearch's design. Eg: I have 3 foreign keys referencing a table of schools. I want them to all act the same way, but Livesearch forces me to create 3 separate remote callbacks with the ids of each of the fields, seeing as HTML requires that ids are unique. Of course the workaround would be to have 3 unique functions which reference the same function, but workarounds are a symptom of poor design ;) This could easily get out of hand for an app with a larger number. I also like to name my functions with action phrases and my element ids do not look like my function names. So forcing people to use function names the same as element ids makes the code a bit harder to understand. And lastly, it took me a while to figure this out as there's no documentation and the example didn't state this important relationship. I had to go into the livesearch code to figure this out. I believe there should be an option called "reverse_callback" to set the name of the remote callback (as this callback does a reverse lookup of your options). Additionally, the "callback" option should be renamed to "forward_callback" as this does the opposite. Again I'd be happy to supply a patch as I need to get this plugin to do these things asap and I'll probably attempt to modify them myself.

Comments

 [2008-07-12 09:06 UTC] thesee (Giuseppe Dessi)
The html_quickform_livesearch depend on HTML_AJAX, so this piece of "logical" is completely grabbed and revisited from HMTL_AJAX, refer to http://bluga.net/projects/HTML_AJAX/examples/slow_livesearch.php I'll take a look tho this request and if it's possible i'll patch this for next release.