We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8741
    • 17 Posts
    I’m trying to build a form using eForm and I came across an issue where eForm seems to be changing my css classes.

    Here’s some of the HTML before the form is submitted (notice the class names):

    <td width="190" valign="top">
          	<input class="hideWithdraw" name="Frequency" type="radio" value="X" checked="checked"  /> One-Time Gift<br />
            <input class="showWithdraw" name="Frequency" type="radio" value="M" /> Monthly
    </td>
    <td width="272" valign="top">
          	<input class="showWithdraw" name="Frequency" type="radio" value="Q" /> Quarterly<br />
            <input class="showWithdraw" name="Frequency" type="radio" value="A" /> Annually
    </td>
    


    Below is the same code, but this is after the form was submitted and was returned because the form did not pass validation. Notice the class name on the first input tag:
    <td width="190" valign="top">
          	<input class="showWithdraw" name="Frequency" type="radio" value="X" checked='checked' /> One-Time Gift<br />
    	<input class="showWithdraw" name="Frequency" type="radio" value="M"  /> Monthly
    </td>
    <td width="272" valign="top">
          	<input class="showWithdraw" name="Frequency" type="radio" value="Q"  /> Quarterly<br />
            <input class="showWithdraw" name="Frequency" type="radio" value="A"  /> Annually
    </td>
    


    Please ignore the hideous HTML. This is my quick and dirty code...

    Any idea why eForm would change the class name?

    Thanks
      • 8741
      • 17 Posts
      Ok, I think I’m onto something. I can see in the $fields array that eForm makes note of any classes that are assigned to a form element. You can see here:

      Frequency_class=showWithdraw

      However, it doesn’t know that not all of the related elements may not have the same class(es), as you can see in my previous post.

      So I guess my question has now changed. Any idea how to keep eForm from fiddling with the class names in the form? If everything passes validation, it’s fine, because it has no reason to redisplay the form. But if there’s a validation error, eForm redisplays the form showing the errors, but has now made all of the css classes for that particular element the same.

      Any help would be much appreciated! By changing class names it is breaking some jQuery functionality I’m trying to use.
        • 10532
        • 5 Posts
        Does the post below address your issues? Perhaps an issue with duplicated names?

        http://modxcms.com/forums/index.php/topic,37871.0.html
          • 8741
          • 17 Posts
          Quote from: GavinMcGimpsey at Aug 12, 2009, 10:03 AM

          Does the post below address your issues? Perhaps an issue with duplicated names?

          http://modxcms.com/forums/index.php/topic,37871.0.html

          Thanks for the post. The only place there are duplicated names are for radio button groups. I went through my form again and everything looks ok.

          As a stop gap measure I just used unique id’s on each radio button for my jQuery instead of referencing their class names. Fortunately that radio button group is only four options.

          So I’m still looking for a solid solution...
            • 17546
            • 75 Posts
            Hello,

            I ’up’ this post, because eForm change my class name, and I find a solution, just choice a differente ’name’ and unique for each of your ’input’ or other ’radio/button’ elements.

            That’s all, I hope this solution (very simple) can help someone else.

            Good day.
            Low.
              Low