Extension talk:Page Forms/Autocompleting on outside values
This does not make sense to me. Can anyone provide a better example?
Not working in 2.1.2?
editAfter upgrading to 2.1.2 this is not working for me (I changed 'autocomplete from url' to 'values from url'). Any ideas about how to find the problem? rotsee 09:22, 1 April 2011 (UTC)
- That's too bad - it works for me. "autocomplete from url=" should still be supported (there's backwards-compatibility) - does that one still work? Yaron Koren 15:23, 1 April 2011 (UTC)
- Sorry, that's my bad for not reading the updated docs. I didn't change 'input type' to 'text with autocomplete'. rotsee 07:57, 12 April 2011 (UTC)
Struggling to make it work. All components seem correct to me.
editHi all,
I'd really appreciate a few pointers here. I'm creating a form that allows autocompletion on Mediawiki user names via a little bit of a hack but I'm trying to learn this technique so I can use it elsewhere (If you know of a better way of autocompletion on user names, I'd be happy to hear it :).
I've done the following:
1) Created a php script that selects of the mediawiki user database and return's the required JSON format
- The URL:
http://127.0.0.1/IZAZIWIKI/UserList.php?search=Jan
- The response:
{"sfautocomplete":[{"title":"Jannie du Preez"}]}
2) Defined a form with the correct field defined:
{{{field|KT_SME|input type=text with autocomplete|values from url=URL-user_names}}}
3) Edited LocalSettings.php with the following line:
$sfgAutocompletionURLs['URL-user_names'] = 'http://127.0.0.1/IZAZIWIKI/UserList.php?search=<substr>';
I know that the UserList.php
is being called by the form and the search string is being passed correctly (I write the query string to a file in the UserList.php
file) but the problem is that no values are proposed and the spinning wheel in the input field spins continuously.
Any help would be greatly appreciated.
- MediaWiki version: 1.19.2
- Semantic MediaWiki version: 1.8
- Semantic Forms version: 2.5.1
--Ironswalt (talk) 19:09, 12 May 2013 (UTC)
- The easier way to do this autocompletion is with "values from namespace=User", although it won't work for users that don't have a user page created. (You might consider using the Semantic Signup extension, by the way, to force creation of user pages on registration.) I don't know what the issue is here, though - the Javascript is hitting the URL correctly, and the URL returns values correctly, so I don't know. Maybe it's the fact that it's 127.0.0.1, i.e. localhost, instead of a real IP address? Yaron Koren (talk) 23:27, 12 May 2013 (UTC)
- Okay I've found out a little more. When calling my service directly it returns the string
{"sfautocomplete":[{"title":"Jannie du Preez"}]}
correctly (as per point 1 above). - But when I use the form entry and check the debug console in Firefox I see the following URL being sent:
http://127.0.0.1/IZAZIWIKI/api.php?action=sfautocomplete&format=json&external_url=URL-user_names&substr=Jan
. This instead returns the following string:{"sfautocomplete":[{"title":{"title":"Jannie du Preez"}}]}
. I've tried to compensate for the extra{"title":
but nothing I'm doing works. - Any ideas as to what I'm doing wrong? Thanks in advance for any assistance.
- Okay I've found out a little more. When calling my service directly it returns the string
- Hi - oh yes... now it's coming back to me. I'm pretty sure this was a bug that was fixed in the most recent version of SF, 2.5.2. Sorry about that. If you get the latest version, it should work. Yaron Koren (talk) 15:29, 13 May 2013 (UTC)
- Thanks so much for the help, I've got it working now. Great software! --Ironswalt (talk) 05:32, 14 May 2013 (UTC)