Skip to Content Skip to Menu

[SOLVED] Autofill field with table query

  • Sekulla
  • Sekulla
  • OFFLINE
  • Posts: 43
  • Thanks: 3
  • Karma: 1
4 years 6 months ago - 4 years 6 months ago #318229 by Sekulla
Hi This might be a simple question but maybe I am not seeing the wood for the trees.

I am trying to setup a profile field that contains a Company name. No problem so far.

However, I would like to have the field start to autofill as the user types with company names that are already stored in a K2 table if the company exists.

I have been playing around with CB query and CB auto actions but cant seem to find a route to set this user case up.

I would appreciate any clues or tips to set me in the right direction, even if the answer is 'it is not possible without custom php coding'.

Thanks for any help
Last edit: 4 years 6 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48550
  • Thanks: 8290
  • Karma: 1445
4 years 6 months ago #318243 by krileon
Replied by krileon on topic Autofill field with table query
Yup, that's doable. You can do PHP based or SQL based autocomplete. Since you already have a database of this information I recommend SQL based autocomplete. For that you'll need CB Query Field. Once installed and published simply edit your Text field (autocomplete is only supported on text based fields) then under Integrations > CB Query Field > Auto Complete you can configure the SQL your autocomplete will use (please be sure to read parameter descriptions carefully). If you need PHP you can do the same with CB Code Field except you'll be able to write your autocomplete usage with custom PHP.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • Sekulla
  • Sekulla
  • OFFLINE
  • Posts: 43
  • Thanks: 3
  • Karma: 1
4 years 6 months ago #318254 by Sekulla
Replied by Sekulla on topic Autofill field with table query
Hi Krileon,

Many thanks for the hint, I would prefer to go the SQL/CB query route and was looking at that approach but could not find an "autocomplete" option! I can easily set up the text field and CB query SQL to check if the entry exists in the table and give a success or fail message but cannot get it to autocomplete as I type to select an existing entry. Am I missing something or a plugin? See screen shots.
Attachments:

Please Log in or Create an account to join the conversation.

  • Sekulla
  • Sekulla
  • OFFLINE
  • Posts: 43
  • Thanks: 3
  • Karma: 1
4 years 6 months ago #318264 by Sekulla
Replied by Sekulla on topic Autofill field with table query
PLEASE SHOOT ME!!! I was using v5 of CB Query and not v6.!!!!!!

So all is now well and you can ignore the above post. v6 has the new tab autocomplete and I am using the SQL

SELECT catid, title FROM cop19_k2_items WHERE catid = '3' AND title LIKE '[value]%'

Which pulls out all company names for autocomplete in the text field for companies if my table that have a catid of 3.

It works really well, sorry for wasting your time.
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum