Jump to:

10376 Posts in 2191 Topics by 1708 members

All other Modules

SilverStripe Forums » All other Modules » Universal Autocomplete Field

Discuss all other Modules here.

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 3460 Views
  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Universal Autocomplete Field Link to this post

    I installed this on a site build on SS 2.4.0 rc1, specifically in two instances on an object managed in ModelAdmin. One instance in the dataobject being managed, and one in a has_many relation managed through a DOM popup.

    The one in the DOM popup works fine, but the one on the parent dataobject doesn't do a thing. It is the AutocompleteField input, just doesn't do any of the autocomplete javascript.

    I added a console.log call to the autocomplete javascript (the one that mobius listed) and this only is called on the popup, not on the parent instance. Anyone have any ideas why this may be?

  • otherjohn
    Avatar
    Community Member
    125 Posts

    Re: Universal Autocomplete Field Link to this post

    Has anyone gotten this to work for SS 2.4
    It's not working for me. I will try to debug what is going on.
    John

  • martimiz
    Avatar
    Forum Moderator
    875 Posts

    Re: Universal Autocomplete Field Link to this post

    Hi all - and thanks anonimous user, whoever you are

    I've got it working (as a test) in ModelAdmin 2.4. Using the download from the 3rd post in this thread, added Mobius' fix and two of my own:

    1. in AutocompleteField, line 221 replace

    $response = new HTTPResponse($body);

    with:

    $response = new SS_HTTPResponse($body);

    2. When using the field in ModelAdmin: this works when editiong an existing record, but not when adding a new one. This is because the latter doesn't use EditForm, it uses AddForm. So in AutocompleteField.js, replacing:

    AutocompleteField.applyTo('#Form_EditForm input.AutocompleteField');

    with

    AutocompleteField.applyTo('input.AutocompleteField');

    will make that work as well (can't think of any horrible implications just yet).

    Cheers, Martine

    P.s.: I'm not using the DataObject Manager, so no idea about any problems there...

  • martimiz
    Avatar
    Forum Moderator
    875 Posts

    Re: Universal Autocomplete Field Link to this post

    Looks like loading the jQuery UI breaks the field. The only core object loading the UI seems to be the FileIframeField, and because that is used by the Image Field, you can't have an ImageField and the AutocompleteField on the same form. Since I can't see the UI being used (?) I just block it from the AutocompleteField::Field() method:

    Requirements::block(THIRDPARTY_DIR . '/jquery-ui/jquery-ui-1.8rc3.custom.js');

    A bit crude maybe, but eh... Maybe it's the Autocomplete plugin in the UI? Anyway, the only other object I saw using the UI is the DOM. Haven't tested it, since I don't use the DOM so much, but I thought I'd mention.

  • Querdenker
    Avatar
    Community Member
    2 Posts

    Re: Universal Autocomplete Field Link to this post

    In case somebody is still trying to use the AutocompleteField in the ModelAdmin - i got it working and posted my solution here: http://code.google.com/p/ss-module-formfields/issues/detail?id=1

    3460 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.