We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10357
    • 573 Posts
    Hi,

    I am using the language file to output formatted error messages. In the case of my email field i have:

    $_lang["ef_invalid_email"] = "<div class=’error’> Email is not valid.</div>";

    the problem is the words email address is added to the error message, which falls out site my error div. Where do these extra words come from?
      • 30223
      • 1,010 Posts
      From your form’s input fieldd,... either the field name or the caption you placed in the eform attribute of the input field. This is necessary so that if you have 2 email fields in your form for instance, there can be no misunderstanding about which field contains the error.
        • 10357
        • 573 Posts
        thanks, but how can I wrap ’email address’ inside the div.

        I guess this is a shortcoming of the current system ?
          • 30223
          • 1,010 Posts
          Calling it a shortcoming is a bit much don’t you think? The strings in the language file are mostly simple default messages for your convenience, they are not templates.

          However, if you must,.. have a look at line 202 in eform.inc.php and adjust at your leisure

          $vMsg[count($vMsg)]=$desc . $_lang["ef_invalid_email"];
          


          You could for instance change it to:
          $vMsg[count($vMsg)] = isset($fld[4]) ? $fld[4] : $desc . $_lang["ef_invalid_email"];
          

          in which case the error message would be taken from the eform attribute of the field if that was set. That would be an improvement I’d be inclined to add to the code , although it probably doesn’t do what you want.

          Alternatively change it to
          $vMsg[count($vMsg)]= str_replace('[+desc+]', $desc,  $_lang["ef_invalid_email"]);
          

          and make your language string something like
          $_lang["ef_invalid_email"] = "<div class='error'>[+desc+] is not a valid email address.</div>";
          

            • 10357
            • 573 Posts
            Hi TobyL,

            many thanks for your help, the fix works great for me.

            Sorry if I offended you, i simply meant that it was not possible to do what i wanted in current system. I imagine wanting to wrap the errors message in a div is a fairly common requirement.