Let the platform do the work

Removing Required Fields From Web-to-Lead Forms

Overview

Sugar® provides a simple way to allow visitors to your website and other online locations to become lead records in your Sugar instance. When creating web-to-lead forms, any fields that are marked as required in the Leads module must be included on the lead form. However, there may be occasions where you find it unnecessary to include certain required fields on your web-to-lead form. This article will cover how to remove such required fields from the HTML for a web-to-lead form. Please note that the information in this article will also apply if you wish to remove any unrequired fields from the web-to-lead form.

Beginning with version 9.1.0, each user's license type (e.g. Sugar Serve) determines what functionality is available as described in the License Types Matrix documentation. Please note that the Campaigns module is not available for Sugar Serve users.

Use Case

Sarah's company has made the Primary Address Country field required in Admin > Studio for their Leads module. Sarah wants to create a web-to-lead form in Sugar but does not want to ask potential leads to supply their country on the form. As an example, we will cover how to remove the Primary Address Country field from the HTML for a web-to-lead form. 

Prerequisites

You must be familiar with creating a web-to-lead form. For more information, please refer to the Creating a Web-to-Lead Form article.

Steps to Complete

Use the following steps to remove the Primary Address Country field from a web-to-lead form:

  1. Create the web-to-lead form by selecting "Create Lead Form" in the Campaigns module tab's actions menu. For this example, add the following fields to the lead form:
    • First Name
    • Last Name
    • Primary Address Street
    • Primary Address City
    • Primary Address State
    • Primary Address Postal Code
    • Primary Address Country
  2. Once the form is populated, click the Save Web To Lead Form button at the top of the page.
    SaveWebToLeadForm2
  3. Copy the HTML generated on the screen and paste it into your favorite text editor (e.g. WordPad). 
    SavedLeadForm HTML
  4. Locate the required field that you wish to remove from the form, Primary Address Country, in the HTML. Each form field is contained within <tr> tags in the HTML, similar to this:
    <tr>
    <td style="text-align: left; font-weight: normal;" width="15%"><span>Primary Address Country: <span class="required" style="color: #ff0000;">*</span></span></td>
    <td style=" font-weight: normal;" width="35%"><span><input id="primary_address_country" type="text" name="primary_address_country" /></span></td>
    <td style="text-align: left; font-weight: normal;" width="15%"><span>&nbsp;</span></td>
    <td style=" font-weight: normal;" width="35%"><span>&nbsp;</span></td>
    </tr>
  5. Remove the code for the Primary Address Country field from the HTML. Be sure to delete the entire table row, including the opening <tr> and closing </tr> tags.
  6. Next, look at the HTML again and locate the code listing each required field (e.g. Last Name and Primary Address Country) displayed on the form. It typically appears toward the end of the <table> code and looks similar to this:
    <tr>
    <td style="display: none;"><input id="req_id" type="hidden" name="req_id" value="last_name;primary_address_country;" /></td>
    </tr>
  7. Remove primary_address_country; from the line of code. The code should now look similar to this:
    <tr>
    <td style="display: none;"><input id="req_id" type="hidden" name="req_id" value="last_name;" /></td>
    </tr>
  8. Copy the remaining HTML from the text editor and paste it into the final destination (e.g. your website) where the lead form will be hosted.

Application

Once the appropriate changes have been made per the steps above, the lead form on the website will no longer contain the Primary Address Country field.
finalform

Please note that, even though the Primary Address Country field is removed from the lead form, it is still required for the Leads module in Sugar. When a user edits the lead records generated via this form in Sugar, they will have to enter a value for the Primary Address Country field in order to save the record. Another option would be to make the Primary Address Country field no longer required via Admin > Studio. For more information on making this change, please refer to the Making a Field Required or Unrequired article.