On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi forum,
    I recently made an update from 1.0.4 to 1.0.9 on a site with many forms based on eform. All forms have many checkboxes with strings as values. They all don't work anymore. If the form is submitted, validation throws a ef_failed_default => "Incorrect value"; in my language (german).

    I don't use name="myValues[]", I have just defined many separate input tags with different names.

    If I replace the value with an integer, validation works as expected. I could change the values to integers and replace the contents in eformOnBeforeMailSent, but this would be a big amount of work.

    Anyone an idea? smiley

    Thx in advance.

    PS: An Update to 1.0.10 didn't help.
    PPS: On 1.0.8 upgrades, everything is fine. [ed. note: mr.odo last edited this post 6 years, 5 months ago.]
    • My workaround for this problem:
      [!emailFormUserInfo!]
      [!eForm? &eformOnBeforeMailSent=`emailFormUserInfo` &formid=`ContactForm` ... !]

      Before the eForm-call, the snippet emailFormUserInfo is loaded. The eForm-call uses &eformOnBeforeMailSent=`emailFormUserInfo`, that activates function emailFormUserInfo from the snippet above before mail is sent.
      <?php
      function emailFormUserInfo (&$fields) {
      
      	// Checkboxes
      	$checkBoxes = array (
      		'myCheckbox01' => '[x] some request',
      		'myCheckbox02' => '[x] another strange demand',
      	);
      	foreach (array_keys($checkBoxes) as $checkBox) if (strlen($fields[$checkBox]) > 0) $fields[$checkBox] = $checkBoxes[$checkBox];
      
      	...
      
      	return true;
      }
      ?>
      Note, that strlen() of the checkbox's value has to be greater than 0. isset() doesn't work here, it is always true.

      I've changed HTML for checkboxes from
      <input type="checkbox" name="myCheckbox01" value="[x] some request" eform="some name 01::1"  />
      <input type="checkbox" name="myCheckbox02" value="[x] another strange demand" eform="some name 02::1"  />
      to
      <input type="checkbox" name="myCheckbox01" value="1" eform="some name 01::1"  />
      <input type="checkbox" name="myCheckbox02" value="1" eform="some name 02::1"  />
      by replacing strings with integers.

      Surely, this issue can be fixed much more elegant. At least, I was glad to have the forms working again and my customer didn't explode.
      Every form with a mandatory checkbox and string value probably won't work anymore. [ed. note: mr.odo last edited this post 6 years, 5 months ago.]