I need to update a Drupal 10 Webform so that it allows the user to pick a school in our database by name and/or postcode. This is because there are a very large number of schools with very similar names e.g. St Mary's ..., and the autocomplete or Select list will not do the job. We end up with the wrong school selected.

I already have an existing Drupal View that does this for internal use, but I'd like to incorporate this functionality without the limitations of linking to this View and using a result link to return to the form with a contact ID for the Existing Contact i.e. I stay on the form to give the best user experience.

I came across this old blog Using Drupal Search and Facet APIs with CiviCRM Data and in principle this approach, updated for D10, would seem to be the answer?

Our CiviCRM and Drupal Databases are separate. When I add the database server and indices I get a PHP exception:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_dev.civicrm_address' doesn't exist:

For D7 you had to include in settings.php a section with all the CiviCRM tables, but this is no longer the case with CiviCRM Entity.

So my questions are:

  1. Should I use the Drupal Search API approach as broadly outlined in the old blog and if not, what's the best way?
  2. Is my environment set up properly re the settings.php - you no longer get a list of tables?

I can imagine this is not an uncommon use case, so hoping the answer to my question will benefit lot of people that the original blog was aimed at but are upgrading Drupal from 7 to 10.

1 Answer 1


You can use Search API with CiviCRM Entity If you have CiviCRM tables in a separate database than Drupal tables, you need this PR: https://github.com/eileenmcnaughton/civicrm_entity/pull/450

  • Many thanks - I initially misunderstood but it looks like all I need to do is add the $databases['civicrm']['default'] into my drupal settings file. Looks like it's indexing but I'll have to wait and see. I'll update this if I have configured it correctly.
    – ChumKui
    Commented Feb 23 at 22:53
  • Everything indexed fine (it took a long time due to the size of the database) so I'll look at the rest of the solution.
    – ChumKui
    Commented Feb 25 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.