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

    I’m using eform 1.4.4 with Modx 0.9.6 and have a problem with automatic validation of select boxes.

    My eform chunk looks like this:
    <select name="region" id="region" size="1" eform="Region:integer:1::#RANGE 1~81" />
    	[[Townlists? &mode=`selectlist` &limit=`0`]]
    </select>
    


    The ’Townlists’ snippet produces a list like this:
    <option value=""></option>
    <option value="1">Town1</option>
    <option value="2">Town2</option>
    <option value="3">Town3</option>
    <option value="4">Town4</option>
    <option value="5">Town5</option>
    ...
    


    But eform does not accept the values of this select box.

    The following validation rules I tried already without success:
    eform="Region:integer:1::"
    eform="Region:integer:1"
    eform="Region:integer:1::#RANGE 1~81"
    eform="Region:integer:0::#RANGE 1~81"
    eform="Region:integer:1::#RANGE 1-81"
    eform="Region:integer:0::#RANGE 1-81"
    


    The eform error messages are all the time: ’Incorrect value’
    or with #RANGE field: ’Value not in permitted range’.

    How is eform accepting ’dynamic’ select values? Or do I have a syntax error in my eform validation rules?

    Many thanks for help.
      • 30223
      • 1,010 Posts
      There are several examples floating around in the forum on how to do this and why the way you have tried this does not work (which basically comes down to the fact that what you see in your browser is not the same as what eForm can see when it parses the form. The Townlists snippet is evaluated AFTER eform has finished)

      Have a look at this article in the wiki
        • 27397
        • 8 Posts

        First thanks for your immediate response TobyL.

        I took a look on the link you proposed and it seems quite complicated. Wouldn’t it be much easier to do this?

        Inserting only one effective line (88) of code in eform.inc.php (Lines 87 and 88 are new):
        84  //required
        85  if( $tmp=efLoadTemplate($tpl) ) $tpl=$tmp; else return $_lang['ef_no_doc'] . " '$tpl'";
        86
        87  //execute snippets inside form template, snippet call should be [[ ... ]]
        88  $tpl = $modx->evalSnippets($tpl);
        89  
        90  # check for valid form key
        91 if ($formid=="") return $_lang['ef_error_formid'];


        After inserting line 88 in eform.inc.php snippets inside the chunk are evaluated before eform starts form validation. Not much tested jet but seems to work fine.

        Nevertheless I would recommend including your link to the eform documentation delivered with the code.
          • 30223
          • 1,010 Posts
          Something similar is indeed on the table for an upcoming release of eForm.

          Nevertheless I would recommend including your link to the eform documentation delivered with the code.

          The documentation was written before the wiki existed, but I’ll keep your suggestion in mind smiley
            • 4888
            • 3 Posts
            I have a similar problem. But in my case is a javavascript filter! Can you help me?

            http://www.interactivo.cl/dev/mobile.kia/cotizar

            When I select a "Región" I have dynamicaly created the "Comuna" and "Concesionarios" options.

            The eForm returns me a "invalidField" in the "Comuna" selector.

            I understand the problem is the same with the snippet but needs another solution.

            I know that this javascript is not the better option but is what i have

            <div class="divline">
            <label class="inputlabel" for="cbRegion"><em>*</em> Región</label>
            <select name="cbRegion" id="cbRegion" onChange="redirect(this.options.selectedIndex,0,0)" eform="Seleccione su región:select:1" />
            <option value="0">Seleccione una Región</option>
                 <option value="1" >I Región</option>
                 <option value="2" >II Región</option>
                 <option value="3" >III Región</option>
                 <option value="4" >IV Región</option>
                 <option value="5" >V Región</option>
                 <option value="6" >VI Región</option>
                 <option value="7" >VII Región</option>
                 <option value="8" >VIII Región</option>
                 <option value="9" >IX Región</option>
                 <option value="10" >X Región</option>
                 <option value="11" >XI Región</option>
                 <option value="12" >XII Región</option>
                 <option value="13" >Región Metropolitana</option>
                 <option value="14" >XIV Región</option>
                 <option value="15" >XV Región</option>
            </select>
            </div>
            
            <div class="divline">
            <label class="inputlabel" for="cbComuna"><em>*</em> Comuna</label>
            <select name="cbComuna" id="cbComuna"  onchange="javascript:fncCambiaCodigoArea(document.formulario,this.value,codigos);"  eform="Seleccione su Comuna:select:0" />
            <option>Seleccione su Comuna</option>
            </select>
            </div>
            
            <div class="divline">
            <label class="inputlabel" for="concesionarios"><em>*</em> Concesionarios</label>
            <select name="cbConcesionario" id="cbConcesionario" eform="Seleccione su concesionario:select:1" />
            <option>Seleccione</option>
            <!--<option value="104" >COM. AUTOM. MIRANDA LTDA. (IQUIQUE)</option>-->
            <!--<option value="344" >Com. Aut. Miranda Mall AutoPlaza (Calama)</option>-->
            <!--<option value="15" >COM. AUTOM. MIRANDA LTDA.(ANTOFAGASTA)</option>-->
             <!--<option value="14" >COM. AUTOM. MIRANDA LTDA.(CALAMA)</option>-->
            <!--<option value="320" >Indumotora ONE (Mall Antofagasta)</option>-->
            <!--<option value="340" >Indumotora ONE (Pac Antofagasta)</option>-->
            <!--<option value="16" >CALLEGARI LTDA.(COPIAPO)</option>-->
            <!--<option value="17" >CALLEGARI LTDA.(LA SERENA)</option>-->
            <!--<option value="18" >CALLEGARI LTDA.(OVALLE)</option>-->
            <!--<option value="328" >AUTOMOTRIZ ROSSELOT (QUILLOTA)</option>-->
            <!--<option value="345" >AUTOMOTRIZ ROSSELOT S.A.(CHACABUCO-VALPARAISO)</option>-->
            <!--<option value="102" >AUTOMOTRIZ ROSSELOT S.A.(SN ANTONIO)</option>-->
            <!--<option value="34" >AUTOMOTRIZ ROSSELOT S.A.(Viña del Mar)</option>-->
            <!--<option value="20" >TOCORNAL AUTOS S.A.(LOS ANDES)</option>-->
            <!--<option value="19" >TOCORNAL AUTOS S.A.(SN FELIPE)</option>-->
            <!--<option value="35" >AUTOMOTORA ALAMEDA LTDA.(RANCAGUA)</option>-->
            <!--<option value="22" >AUTOMOTORA ALAMEDA LTDA.(SN FDO)</option>-->
            <!--<option value="111" >AUTOMOTORA ALAMEDA LTDA.(CURICO)</option>-->
            <!--<option value="326" >BALADRÓN E HIJOS LTDA. (LINARES)</option>-->
            <!--<option value="24" >BALADRÓN E HIJOS LTDA.(TALCA)</option>-->
            <!--<option value="26" >COMERCIAL COPELEC S.A. (CHILLAN)</option>-->
            <!--<option value="36" >SALAZAR ISRAEL  LTDA. (Los Angeles)</option>-->
            <!--<option value="342" >SALAZAR ISRAEL LTDA. (Paicaví, Concepción)</option>-->
            <!--<option value="319" >SALAZAR ISRAEL LTDA. (Plaza Trebol, Concepcion)</option>-->
            <!--<option value="51" >SALAZAR ISRAEL  LTDA. (Prat, Concepcion)</option>-->
            <!--<option value="27" >SALAZAR ISRAEL  LTDA. (Sucursal Vega Monumental)</option>-->
            <!--<option value="28" >SALAZAR ISRAEL LTDA.(Temuco)</option>-->
            <!--<option value="30" >AUTOMOTRIZ ARAUCO LTDA.(OSORNO)</option>-->
            <!--<option value="123" >EXEQUIEL BERRIOS Y CIA. LTDA. (CASTRO)</option>-->
            <!--<option value="120" >EXEQUIEL BERRIOS Y CIA. LTDA. (PTO. MONTT)</option>-->
            <!--<option value="30" >AUTOMOTRIZ ARAUCO LTDA.(OSORNO)</option>-->
            <!--<option value="123" >EXEQUIEL BERRIOS Y CIA. LTDA. (CASTRO)</option>-->
            <!--<option value="120" >EXEQUIEL BERRIOS Y CIA. LTDA. (PTO. MONTT)</option>-->
            <!--<option value="97" >AUTOCORP LTDA. (Manuel Montt)</option>-->
            <!--<option value="327" >AUTOMOTORA VALP S.A. (Bellavista)</option>-->
            <!--<option value="126" >AUTOMOTRIZ PORTILLO S.A. (La Dehesa)</option>-->
            <!--<option value="5" >GRASS &ARUESTE LTDA. (IRARRAZAVAL)</option>-->
            <!--<option value="13" >GRASS &ARUESTE LTDA. (Plaza Vespucio)</option>-->
            <!--<option value="39" >GRASS &ARUESTE LTDA. (VICUÑA)</option>-->
            <!--<option value="335" >Indumotora ONE (Bilbao/Vespucio)</option>-->
            <!--<option value="12" >Indumotora ONE  (La Portada)</option>-->
            <!--<option value="330" >Indumotora ONE (Mall Plaza Alameda)</option>-->
            <!--<option value="112" >Indumotora ONE  (Mall Plaza Norte)</option>-->
            <!--<option value="333" >Indumotora ONE (Mall Plaza Sur)</option>-->
            <!--<option value="10" >Indumotora ONE (Movicenter)</option>-->
            <!--<option value="11" >Indumotora ONE (Sta. Rosa/Sta.Isabel)</option>-->
            <!--<option value="341" >Indumotora ONE (Vitacura)</option>-->
            <!--<option value="329" >POMPEYO CARRASCO (Arauco Maipú )</option>-->
            <!--<option value="109" >POMPEYO CARRASCO (Autoplaza-Tobalaba)</option>-->
            <!--<option value="6" >POMPEYO CARRASCO (Gran Avenida)</option>-->
            <!--<option value="346" >POMPEYO CARRASCO (Maipú )</option>-->
            <!--<option value="110" >POMPEYO CARRASCO (Plaza Oeste)</option>-->
            <!--<option value="29" >EXEQUIEL BERRIOS Y CIA. LTDA. (Valdivia)</option>-->
            </select>
            </div>
            


            For more info visit the link a view the script at the end of the page code http://www.interactivo.cl/dev/mobile.kia/cotizar

              • 4888
              • 3 Posts
              I just found the solution to my problem
              http://forums.modx.com/thread/47439/eform-dropdown-incorrect-value-error-solved#dis-post-274361

              "In select box we just change the rule of #LIST by using calling eform="::0::#EVAL return true;" in select box like"

              :)