We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20732
    • 7 Posts
    I am living in Denmark where we have a couple of national letters beyond A through Z - amongst these are ø å etc. I have been looking into the eform code to see where I should add a call to the htmlentities() PHP function to have the literal characters in form input translated to the corresponding HTML entity before using them in the ACK form or in the report. I do not seem to be able to locate the exact spot. Is it possible that anybody here could provide a hint?
      • 30223
      • 1,010 Posts
      In the current version you can do this using the eFormOnbeforeMailSent event.

      Create a snippet with the following function: (you can add details yourself)..
      <?php
      //snippet "eFormFunctions"
      //recursive function for applying htmlentities to values
      beforeMailSentFunction( &$fields ){
          foreach($fields as $key =>$value){
              if( is_array($value) ) 
                  //as this is also called by reference $value will be updated
                  beforeMailSentFunction( $value ); //recursive
              else
                  $value = htmlentities( $value );
      
              $fields[$key]=$value;
          }
          return true; //important!
      }
      ?>
      


      Now in the document where you have the eform snippet call place a call to teh above snippet as well (before th eform snippet) and set the eformOnBeforeMailSent paramter to the funtion name.

      [[eFromFunctions]] <!-- cached -->
      [!eForm eFormOnBeforeMailSent=`beforeMailSentFunction` ...more params... !] <!-- uncached -->
      


      That should do it.
        • 20732
        • 7 Posts
        Thanks a lot - that did the job, but I am wondering whether this isn’t a general MODx issue and whether the "correct" solution wouldn’t be to add the conversion to HTML-entities at a much lower level in the core of MODx. Danish cannot be the only language that will have this problem. Most European languages have additions to the alphabet in the form of accents such as the German ’ü’, the French ’ê’ and will hence experience the same problems as I have seen with Danish.

        /Mads
          • 16827
          • 1 Posts
          I agree with mwestermann, maybe this could be implemented to the core of eForm. I’m from Latin America and most languages spoken here use acentuation or other special characters...

          When new releases come, couldn’t it have some param like "&htmlentities"? I think it’ll be useful for a lot of non-english websites managed with MODx.
            • 14269
            • 6 Posts
            Look at here:
            http://modxcms.com/forums/index.php/topic,2122.msg50507.html#msg50507

            It works in my case. Hope it helps.

            Jaume