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

    i have alot of trouble getting eForm to accept pre-checked checkboxes. I have a simple chunk that stores the my form including the following input:

    <input value="on" name="lang_de" type="checkbox" checked>

    but whenever eform renders the form using this chunk, "checked" gets completely stripped out of my html code...

    am i missing something ? whats the deal here ?
      • 30223
      • 1,010 Posts
      Try this instead:

      <input value="on" name="lang_de" type="checkbox" checked="checked" /> 
      
        • 28064
        • 8 Posts
        Hi Toby!

        I have tried that before but unfortunately it did not help either.
        It’s a strange problem. I havent looked at the eForm code so much yet but could it be that the else-if "checkbox"/"radio" branch only takes the value of a checked input field and discards the rest ?

        greets
        souls
          • 28064
          • 8 Posts

          checked=’checked’ (single quotes) dit the trick !
            • 28064
            • 8 Posts
            Hey Toby, i notices something else:

            in the current version of eForm (1446) in line 830 you have updated handling of default values for text inputs:

            }else{ //plain old text input field
               //retain default value set in form template
               $fields[$name] = stripTagQuotes($tagAttributes['value']);
            }
            


            when i was trying to fix my problem with pre-checked checkboxes, i suddenly noticed that default values for text input fields were not filled in anymore (using eFormOnBeforeFormParse, storing data to &$fields). This worked
            in version 1445 (where the else branch i posted above did not exist yet). I am not sure, maybe stripTagQuotes messes something up. As a temp. hack i removed the else branch and now everything works fine: default values for my text fields as well as pre-checked check boxes.

            maybe somebody else has the same problem. i need to finish my current project but i will look into that after that.

            souls
              • 13428 ☆ A M B ☆
              • 1,031 Posts
              Maybe there is a bug in stripTagQuotes and you have to put the defaults in single quotes too.
                • 30223
                • 1,010 Posts
                Quote from: souls at Jun 25, 2009, 06:08 AM

                Hey Toby, i notices something else:

                in the current version of eForm (1446) in line 830 you have updated handling of default values for text inputs:

                }else{ //plain old text input field
                   //retain default value set in form template
                   $fields[$name] = stripTagQuotes($tagAttributes['value']);
                }
                


                when i was trying to fix my problem with pre-checked checkboxes, i suddenly noticed that default values for text input fields were not filled in anymore (using eFormOnBeforeFormParse, storing data to &$fields). This worked
                in version 1445 (where the else branch i posted above did not exist yet). I am not sure, maybe stripTagQuotes messes something up. As a temp. hack i removed the else branch and now everything works fine: default values for my text fields as well as pre-checked check boxes.

                maybe somebody else has the same problem. i need to finish my current project but i will look into that after that.

                souls
                Has nothing to do with stripping quotes. The value set in the form template takes precedence over setting values in the event. i.e. It is simply overwriting any values you set in the eFormOnBeforeFormParse event function. The code below handles this more correctly.

                //<?php
                }elseif(empty($fields[$name])){ //plain old text input field
                	//retain default value set in form template if not already set in code
                	$fields[$name] = stripTagQuotes($tagAttributes['value']);
                }