[development] "Subclassing" the standard #autocomplete form widget

Rob Thorne rob at torenware.com
Thu Jan 18 21:41:20 UTC 2007


Darrel O'Pry wrote:
> I would look at the nodereference autoselect widget. It takes a node
> title for input and converts it into an nid before stuffing it in the
> db.
>   
OK, it looks like great minds think alike.  Or at least, I think like 
the CCK team.

I came up with an implementation of this for CiviNode about a year ago, 
where I did look-up by contact name from CiviCRM.  It's a very similar 
problem to what nodereference.module needs to do in CCK.

Very similar problem, and very similar hack:  you append " [NID]" to the 
end of your node titles, and to get the $nid back when the form comes 
back,  you just parse off the " [NID]" string, and save away the nid.

This is almost exactly what I did for the first release of CiviNode.   
Except I used " (CID)".  :-)

I'm guessing that the CCK folks did it for the same reason I did:  it 
didn't require mucking with the JavaScript, and it does work.

I was thinking there was a better way to do this, but the fact the CCK 
did the same thing I did before suggests that some hacks are just better 
than others.

Thanks,
Rob



More information about the development mailing list