Pre-populate a field with the submitter's CAS ID.

You may have any number of reasons why you may need to collect the official Kerberos of CAS ID of the person submitting a webform on your site. It's not immediately obvious how to do it, so let's take a moment to outline the steps.

Create the CAS ID field in your form
  1. Navigate to Manage » Structure » Webforms.
  2. Select your webform from your list of forms and click its Build button.
  3. Click the +Add element button.
  4. From the dialog box go to the section marked BASIC ELEMENTS and select the Text field Add element button.
  5. The edit section will open. Here are the key configurations you will need to make this work:
    • Under the General Tab
      • Title - the field needs a machine name. Consider something like 'UC Davis Username (CAS Login ID)'
      • FORM DISPLAY section: Pre-populate - check the box, look for this at the bottom of the section's list
      • FORM VALIDATION section: Required - check the box, then provide a Required message
      • Save your changes, click the element's Edit button if necessary to return to its configuration options.
    • Under the Advanced Tab
      • DEFAULT VALUE section: enter [cas:username] in the field, including the square brackets.
  6. Save your changes.
Set your webform to have CAS protection
  1. Set this form behind CAS protection in order to force the submitter to login so the form can access their account and insert the CAS ID information in your form:
    • Navigate to Manage » Configuration » SiteFarm section » CAS Settings.
    • From the list of labels in the CAS settings page, click on Forced Login.
      Image of the CAS configuration screen with the Enabled box checked and the Pages text area listing the forms section as an area to be specifically protected.
    • Check the Enable box associated with the help text "If enabled, all pages on your site will trigger this feature. It is strongly recommended that you specify specific pages to trigger this feature below." This tells the system that your site pages are set up for gatekeeping and, if a page or section of your site is included in the Pages section as described in the next step, your site will trigger a CAS log in requirement.
    • In the Pages field, specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is /user/* for every user page. <front> is the front page. When someone tries to navigate to any of the pages or sections in this list, they will be prompted to log in using their CAS ID and password.
      If you're only doing this one form, use:
    • Click Save configuration.
    • Clear your site's cache to finish.