As an alternative to "How can I display an info only field in a webform", we are displaying a read-only View block on a CiviCRM-enabled webform page via Context because one of the fields of the View block is an embedded View (via the Views Field View module).

We are linking to the webform from another view so that we can supply a Contact ID in the URL, allowing the webform to auto-fill with a contact's information. Per the instructions for Generating URL arguments from Views, our link is as follows: /family-info?cid1=[id].

The link correctly supplies the contact ID to auto-fill the webform fields, but does not return any results for the View block that is on the page. I confirmed that the View block is setup correctly because I can supply a contact ID in the View preview in the Views UI and the block information displays correctly. There seems to be a difference between how the webform is reading the URL argument and how the Views block is reading it. Any ideas on how to make the two work together?

Drupal 7.41; Webform 4.12; CiviCRM 4.6.6; CiviCRM-Webform Integration 4.14


After much trial and error, we discovered that the webform and Views block both populate correctly with a supplied link of /family-info?cid=[id]. By removing the 1 between cid and =, the View contextual filter works properly and the webform still auto-fills. I don't know the implications if one were to try to have multiple contact id's, but for our purposes of only one contact id, this resolves the issue.

  • hmm interesting. i think we used some php to do this but can't find it quickly so can't share sorry – petednz - fuzion Dec 19 '15 at 20:23
  • 1
    Yes, when webform_civicrm started supporting multiple contacts the cid url arg was deprecated in favor of cid1 but there no plans to remove support for it as it's useful to have in situations like this. – Coleman Dec 22 '15 at 17:13
  • Thank you @Coleman, that confirms that this can work as a solution and not just a hack we stumbled upon. :-) – Allen Hutchison Dec 22 '15 at 18:46
  • 1
    No prob. Of course if the two modules didn't happen to both support the same argument name (e.g. with multiple contacts) you could always do /family-info?cid=[id]&cid2=[id] to supply it in both forms. – Coleman Dec 23 '15 at 22:38

It looks like we used to do this via the php filter module but stopped doing so for security reasons and have added this snippet of code to a module to provide the contextual filter to the view:

function tidbits_views_pre_build(&$view) {
  if ($view->name == 'your_view'
    && ($view->current_display == 'block_1' || $view->current_display == 'block_2')) {
    $view->args[] = $_GET['cid'];
  • 1
    NB: I am just the messenger, not the developer, I hope the above makes enough sense without more context – petednz - fuzion Dec 19 '15 at 20:46
  • let us know how you got on with it when you know – petednz - fuzion Dec 22 '15 at 7:43
  • Pete, with Coleman's confirmation of how it has worked in the past, I've marked the cid= solution as the answer because it solved this particular issue, but if we have a form that needs multiple contact IDs along with a View, I think your solution (which did make sense) will work. Thank you again. I love this community! – Allen Hutchison Dec 22 '15 at 18:45
  • 1
    ah ha - good to know - might be useful to us sometime time - agree with the community ;-) – petednz - fuzion Dec 22 '15 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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