bound autosuggest only displays selective results?
I've been stumped by this issue and hope someone here can point me in the right direction:
I have a autosuggest field that is bound to a component. When I call the component directly, it works as intended... when I try and use the component through the binding, it doesn't give me the same results.
Here's the autosuggest code:
<cfform name="teamsform">
Search for a team: <br>
Use team name, team id or any part of a team member's name.<br>
<cfinput autosuggest="cfc:/ofcomponents.teams.getteams({cfautosuggestvalue})" autosuggestminlength="2" type="text" name="userSearchTerm" size="50" typeahead="yes"><br>
<input type="submit" value="Go">
</cfform>
Here's the CFC:
<cfcomponent>
<cffunction name="getTeams" access="remote" returntype="string">
<cfargument name="usersearchterm" required="yes" type="string">
<cfquery name="getTeams" datasource="#REQUEST.dsn#">
SELECT t.team_name as name
FROM of_users u left outer join of_teams t on u.of_user_id = t.user_id
WHERE 0 = 0
<cfif arguments.usersearchterm neq "">
and (t.team_name like '%#arguments.usersearchterm#%'
or t.team_id like '%#arguments.usersearchterm#%')
</cfif>
and u.user_type_id in (select user_type_id from of_user_types where user_type_description = 'team')
UNION
SELECT t.team_name as name
FROM of_users u, of_teams t, of_team_participants tp
WHERE u.of_user_id = tp.participant_id and t.of_team_id = tp.team_id
<cfif arguments.usersearchterm neq "">
and u.first_name like '%#arguments.usersearchterm#%'
or u.last_name like '%#arguments.usersearchterm#%'
</cfif>
and u.user_type_id = (select user_type_id from of_user_types where user_type_description = 'participant')
</cfquery>
<!--- <cfdump var="#getteams#">
<cfabort> --->
<cfset returnlist = valuelist(getTeams.name)>
<cfreturn returnlist>
</cffunction>
</cfcomponent>
As mentioned, when I call the component directly, like this:
<cfinvoke component="/ofComponents.teams" method="getTeams" returnvariable="varret">
<cfinvokeargument name="usersearchterm" value="Logan">
</cfinvoke>
<cfdump var="#varret#">
It gives me the correct results (i.e. the Team name)
When I type the same term in the text field, I get no results. When I type in a team name, I only get a result when the team name starts with the search term I am typing. Any other search returns no results.
Can anyone see if I am doing something wrong or is there something else going on that I am not aware of?
Thanks!
