Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

A new suggestion field for SilverStripe

Go to End

3 Posts   1112 Views


Community Member, 400 Posts

16 June 2009 at 7:07pm


I was working on a suggestion form field, I was discussing about this at the google group too, Anyway I'd like to extend the module, and make it a useful plug in.

I am attaching the module here, if you can help me with testing and can give me more ideas that will be great.

Attached Files

Forum Moderator, 4102 Posts

17 June 2009 at 1:29am

Looks good. Haven't used it, but a couple things come to mind:

- You're requiring the user to custom code his own suggestion() AJAX call for every instance of the form field. This may work for users who have really specific functionality, but for most of us, we're going to want that to work out of the box, without any custom coding. It seems to me, you could make it more modular, and add a SuggestionField_Controller class that contains a generic suggestion() function for the AJAX call. You could even assume that the two fields you're looking for are Title and Link, and the user could override those in the constructor.

- You should use MATCH and AGAINST instead of LIKE.

- To get the $URL variable, you can save yourself a lot of trouble and use $('base').attr('href');

- In your Javascript, the line "jQuery.noConflict()" does nothing unless you return that to a variable, for example:

$J = jQuery.noConflict(); $J('#my-element').hide();

- For the suggestion function in the Javascript, you're going to need to use submission throttling to prevent a sequence of rapid AJAX requests. For those of us who are fast typists, we're only going to want to see one ajax call when we're done typing. Not ten of them all at once, one for each keystroke. I did this in the Search function of DataObjectManager if you want an example. You need to store a setTimeout resource and nullify it everytime the user hits a key within say, 0.5 seconds of the last one.

Very nice, though. This is a great idea.


Community Member, 400 Posts

17 June 2009 at 1:55am

hi UncleChees,

thanks for your comments, actually some nice ideas.

About the jQuery.noConflict(); this helps the users to use any other javascript library as well. Sometimes silverstripe too uses prototype, and it can cause conflicts. So this prevents it.

This does need some custom coding, but yet it has some features, it can call to any server using CURL or anything, all you have to do is that return the results in a JSON object. other than that some comments I got was running it through SilverStripe can be slow, so if someone can code up his own php code to run outside then you can have that either.

Also about the setting an interval can be useful.

And on the first post I forgot to mention the demo URL for this.

Here it is