1

I've created a Search Kit that shows only activities of a particular type, and I use Form Builder to build a tab on a contact record with this search. This is very helpful, but we want an "Add Record" button at the bottom of the tab. How can I do this?

1 Answer 1

5

There is no UI to do this, but you can use the Form Code Editor extension, which ships with CiviCRM.

  • Go to Administer menu » System Settings » Extensions and enable the Form Code Editor extension.
  • Go to https://example.org/civicrm/admin/afform-html. (For Drupal/Backdrop, WP is slightly different).
  • Click on the name of the Form Builder form you wish to edit.

You now have an interface to edit the HTML of the Form Builder form directly.

  • Get the URL for the page you want to link to, in my case: https://example.org/civicrm/activity/add?action=add&reset=1&cid=12345&selectedChild=activity&atype=74.
  • Remove the domain name and protocol so it's more portable, and substitute the hard-coded contact ID with the appropriate token. It should then read: /civicrm/activity/add?action=add&reset=1&cid={{options.contact_id}}&selectedChild=activity&atype=74
  • Use standard HTML to add the link to the page. You can use Bootstrap classes to make things look more like the rest of CiviCRM. In my case, the full HTML I added was:
<a class="btn btn-primary" href="/civicrm/activity/add?action=add&reset=1&cid={{options.contact_id}}&selectedChild=activity&atype=74">Add Potential Volunteer Record</a>
  • Don't forget to clear your CiviCRM cache.

When you're done, it will look like this: enter image description here

5
  • thanks Jon. This is really inspiring! Mar 8, 2022 at 9:01
  • what is the need to use 2 brackets around the token: {{options.contact_id}}? Mar 10, 2022 at 8:28
  • This in AngularJS syntax. Mar 10, 2022 at 19:01
  • thanks Jon, important to know. Mar 14, 2022 at 8:48
  • Hi, how do you know that {{options.contact_id}} is a token that is available? Is there a list of these?
    – Ken West
    Jun 6, 2022 at 5:10

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.