We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: sirlancelot at Feb 27, 2007, 06:11 AM

    I’m still struggling with that one! :-/

    It’s a dynamically generated <select> list too...

    I’ve got this piece working for an online survey/assessment module, however it’s probably not the cleanest implementation, IMO.

    I had to "hack" eForm to allow TPL returns from a snippet, and then I have a "select_menu" class that I created referencing small portions of the ADOdb code base... I create the name/value pairs as an array, and pass to an initArray method of the select_menu class...A few decent paramater options too, such as (size, multiple select (bool), blank first item, attribs, etc)

    Using the attributes param, you can easily pass eform psuedo-attribute for validation....
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
      • 30223
      • 1,010 Posts
      Here’s a replacement for the efLoadTemplate function that will let you use snippets for any of the templates:
      <?php
      function efLoadTemplate($key){
        global $modx;
        if( strlen($key)>50 ) return $key;
        $tpl = false;
        if( is_numeric($key) ) { //get from document id
              //try unpublished docs first
              $tpl = ( $doc=$modx->getDocument($key,'content',0) )? $doc['content'] :false;
              if(!$tpl )
                   $tpl = ( $doc=$modx->getDocument($key,'content',1) )? $doc['content'] : false;
      
        }elseif( $key ){ 
              $tpl = ( $tmp=$modx->getChunk($key) )? $tmp : false;
              //try snippet if chunk is not found
              if(!$tpl) $tpl = ( $tmp=$this->modx->runSnippet($key) )? $tmp : false;
        }
        return $tpl;
      }
      ?>
      
      • Awesome! Awesome! Awesome!

        So, when can we expect this HUGE ADDITION (plus some of the minor recent fixes, too) in the repository?? What version does this merit?

        NOTE: Should mention somewhere in the Update/documentation the processing order of Chunks, then Snippet, to prevent confusion for people trying to run snippets named the same as a possible chunk.
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.
          • 30223
          • 1,010 Posts
          As I said in another topic, I’m currently moving house and setting up an art studio/workshop. A new version will have to wait a little while. I’ll probably do another point release as soon as I have the time. I’ve started on a next major version as well but that will be delayed more by the move.

          The new eForm will be class based with these improvements (amongst possibly others)


          • eForm events will have access to the whole class, meaning that you should be able to influence just about everything from within the events.
          • You can declare multiple templates as a comma separated list, mainly for multi-page forms
          • Declare default configuration settings (parameters) in a chunk or config file
          • Add your own custom config parameters
          • Choose custom action to perform. This can be one or multiple actions on successful submit. So you can send an email and save stuff to a database at the same time for instance.
          • Whatever else I’ll come up with before I finish smiley

          Basically the base class will concentrate on form handling and validation. The default number of snippet parameters will greatly be reduced. Actions will be implemented via class extensions or a plugin mechanism (still working on that). For backwards compatibility an email "plugin" with it’s own parameters will be installed by default.

          But as I said.. it’s gonna take a while