web lead email address

We are embedding HTML from the Campaign web to lead form into our website pages.  In an older form, I have the inputID for email address as <input id="email1" and the lead has this email address designated as the primary email address.

On a newer website and form, it is <input id="email".  When we edit the lead to forward or change status, we get an error that an email address is required.  This can be fixed by clicking the star to designate the submitted email address as the primary, but I would like to save this step if possible as it is extra work and confusing. 

I found this article which states that inputID email# is being deprecated and thus the use of <input id="email" is correct.  Is there any way to designate the email address as primary from the form?

Best regards,
Bob

Using e-mail fields correctly in Sugar 

  • You could add the address after you create the lead:

          $lead = BeanFactory::getBean('Leads', $lead_id);
          if($lead->emailAddress->isValidEmail($address)){
               $lead->emailAddress->addAddress($address, true);
          }
          $lead->save();

    the "true" after the address tells it to set it as primary.

     

    there are more parameters you can pass to addAddress, see include/SugarEmailAddress/SugarEmailAddress.php

    public function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null, $validate = true)

     

    FrancescaS