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

    I’ve upgraded to 1.4.4.5 to solve 2 issues I had with previous versions.

    My snippet call looks like:
    [!eForm? &formid=`InformatieForm`  &language=`nederlands` &subject=`Informatieverzoek van [+Naam+]` &to=`an email address` &ccsender=`1` &thankyou=`tpl_informatie_thankyou_form` &tpl=`tpl_informatie_form` &report=`tpl_informatie_report_form` !] 


    My eForm template (tpl_informatie_form) looks like:
    <form method="post" action="[~[*id*]~]">
     
        <fieldset>
        <p class="error">[+validationmessage+]</p> 
            <input type="hidden" name="formid" value="InformatieForm" />
    
            <label for="cfName">Naam:
            </label><input name="Naam" id="cfName" class="text" type="text" eform="Naam::1:" /><br />
            <label for="cfAdres">Adres:
            </label><input name="Adres" id="cfAdres" class="text" type="text" eform="Adres::1:" /><br />
            <label for="cfPlaats">Postcode en plaats:
            </label><input name="Plaats" id="cfPlaats" class="text" type="text" eform="Plaats::1:" /><br />
     
            <label for="cfEmail">Email adres:
            </label><input name="Email" id="cfEmail" class="text" type="text" eform="Email adres:email:1" /><br /> 
    
            <label for="cfVoorNaam">Voornaam kind:
            </label><input name="Voornaam" id="cfVoorNaam" class="text" type="text" eform="Voornaam::1:" /><br />
            <label for="cfAchterNaam">Achternaam kind:
            </label><input name="Achternaam" id="cfAchterNaam" class="text" type="text" eform="Achternaam::1:" /><br />
            <label for="cfGebdatum">Geboortedatum kind (dd/mm/jj):
            </label><input name="Gebdatum" id="cfGebdatum" class="text" type="text" eform="Geboortedatum kind:date:1:" /><br />
             <label for="cfMessage">Opmerkingen:</label>
            <textarea name="Opmerkingen" id="cfMessage" eform="Opmerkingen:textarea:0"></textarea><br />
            
    <p class="error">[+validationmessage+]</p>
     
            <label> </label><input type="submit" name="contact" id="cfContact" class="button" value="Verstuur" />
     
        </fieldset>
     
    </form>


    The form works, but: no email is sent to the user, so ccsender isn’t used. And the date field (name="Gebdatum") is validates as an American date (so, mm/dd/yy), although the language is set to ’nederlands’

    I would think it’s possible to validate against Dutch date rules, but how?

    Thanks.
      • 30223
      • 1,010 Posts
      &ccsender will take the email address from a form field with name="email" Your template has a field with name="Email". Sorry, but eForm is case sensitive...

      As for the date format,... eForm use the php strtotime() function to convert textual dates to unix timestamps. If this is successful the date is considered valid. Sadly the limitation is in php. I don’t know of any equivalent function that takes different locales into account. The best you could do is to write your own validation function for now. Something like this snippet may work for you:

      //<?php //'validateEFormDate' snippet to include date validation function
      if(!function_exists('checkMydate')){
      	function checkMyDate($date){
      		//check if the date is according to day month year format
      		//accepts /, - or space as delimeters
      		list($dy,$mth,$yr) = split('[-/ ]',$date,3); 
      		$rt = strtotime("{$mth}/{$dy}/{$yr}"); 
      		return ($rt===false||$rt===-1) ? false:true;
      	}
      }
      return ''; //snippet returns nothing
      

      Include this code as a snippet on the same page as and before the eForm snippet call. This is a pretty simple function and you may wat to expand on it but I think it might do the job for you (test it though as I didn’t)

      [[validateEFormDate]]
      [!eForm? .....]
      


      Now change your date field to:
      <input name="Gebdatum" id="cfGebdatum" class="text" type="text" eform="Geboortedatum kind:text:1:Ongeldige datum:#FUNCTION checkMydate" /><br />


      Note that for this to work the eform datatype is changed from date to text. This influences the formatting when you display values in your report email but that’s a trade-off I haven’t got a solution for.



        • 26482
        • 138 Posts
        Hi TobyL,

        Thanks for this. I can’t believe yet again I’ve fallen into the case sensitive trap.... grin

        For the date thing, I’ve used your function and checked to see if it is indeed returning false or true for the right dates. It does! However, using this

        <input name="Gebdatum" id="cfGebdatum" class="text" type="text" eform="Geboortedatum kind:text:1:Ongeldige datum:#FUNCTION checkMyDate" />


        code (mind the capital D in checkMyDate), the only validation rule is an empty field. Even if I enter a letter, the form is sent.
        How can I check to see that the function is actually called? An echo statement somewhere in the function doesn’t show up.

        Thanks for your help.
          • 30223
          • 1,010 Posts
          Use a die("I am here:".__FUNCTION__); inside the function to test and it’ll stop everything smiley
            • 32699 ☆ A M B ☆
            • 427 Posts
            Having the same problem.  eform is not calling the function, and it is loaded directly above the eform snippet call.

            Fixed it by:


            Removed cache from page and called like this:

            [[checkPriceField]]
            [!eForm? .....!]
              Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

              Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
              • 18174
              • 116 Posts
              Didn’t work either.
              Just after removing the
              if(!function_exists('checkMydate')){
              condition it worked out, no matter what function name I used. Seems like function_exists() returns a wrong result, I wonder why.
              Regards
              manu