We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11970
    • 10 Posts
    Hello! In my form I use ’select’ with many ’option’, about 150 units. My code looks like

    <select name="sel" eform="::1">[!show_list!]</select>

    and my snippet ’show_list’ exports

    <option value=""></option>
    <option value="item1">Item 1</option>
    <option value="item2">Item 2</option>
    <option value="item3">Item 3</option> and so on.

    I update eForm to version 1.4.4.6 and it crushes with the following error:

    PHP error debug
    Error: #LIST rule declared but no list values supplied: #LIST
    Error type/ Nr.: User Warning - 512
    File: /home/u14945/hospitalitymana/www/assets/snippets/eform/eform.inc.php
    Line: 948

    but I don’t use #LIST anywhere.

    If I limit ’option’ to 10-15 units all works ok.

    Any ideas?

    Thank you!
      • 30223
      • 1,010 Posts
      <select name="sel" eform="::1">[!show_list!]</select>

      eForm parses your form to create automatic validation rules for select boxes by reading all the options and adding them to a #LIST rule. However your [!show_list!] snippet isn’t executed until after eForm has finished it’s work so all that’s in the #LIST rule is the actual "[!show_list!]" string.

      There are 2 ways around this. The first is to add your own validation rule to the select field. For instance a #RANGE rule if the option values are all numeric, or any other rule that is appropriate for your form. See the eForm documentation in assets/snippets/eform/docs/.

      The second is to use the eFormOnBeforeFormParse event and write yourself a function which inserts the options into the form template before it is parsed. As you already have the show_list snippet you can rewrite this or call it from an event function. Something like this in a new snippet should work:

      <?php
      
      if(!function_exists('formParseEvent'){
         function formParseEvent( &$fields, &$templates){
            global $modx;
            $values = $modx->runSnippet('show_list');
            $templates['tpl'] = str_replace['[+option_list+]',$values,$templates['tpl']);
            return true;
         }
      }
      
      return '';
      ?>
      


      changing your select like this:
      <select name="sel" eform="::1">[+option_list+]</select>

      adding the new snippet before the eForm call and adding the event to the eForm call:

      [[eventFunctionSnippet]]
      [!eForm? eformOnBeforeFormParse=`formParseEvent` ....!]
      


      This will let eForm do it’s own ’automatic’ validation with your options list
        • 11970
        • 10 Posts
        Thank you! Thats exactly all, what I am searching for.

        I think adding this information to the documentation or wiki or faq will be a good idea.