Error 42000 executing statement - nonaggregated column 'modx_25.FormItForm.id'

Summary

FormIt causes error:

[2025-12-02 03:17:42] (ERROR @ /home/zane/public_html/core/vendor/xpdo/xpdo/src/xPDO/Om/xPDOObject.php : 227) Error 42000 executing statement:
Array
(
[0] => 42000
[1] => 1055
[2] => Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘modx_25.FormItForm.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
)

Step to reproduce

Submit a form on my site with FormIt and see error in log.

Observed behavior

The form data is not stored and no email is sent to specified recipient.

Expected behavior

Should store form data and send email.

Environment

MODX 3.1.2-pl version

Apache version 2.4.58

MySQL version 8.0.44-0ubuntu0.24.04.1

Chrome is up to date Version 142.0.7444.176

I believe with MySQL 8, the default for the “sql_mode” setting changed, and now includes ONLY_FULL_GROUP_BY.

If possible, you could remove ONLY_FULL_GROUP_BY from “sql_mode” in the config file for MySQL (my.ini) to fix the issue.


Otherwise, you probably have to change the code of the FormIt extra to make the error go away.

I created this pull request on Github a while back that should fix the issue (for MODX 3).

It’s a shame that it hasn’t been merged already.

Well, that’s unfortunate your solution is not used by now.

I removed ONLY_FULL_GROUP_BY from sql_mode and the error goes away but still no save of form data and no email.

[[!FormIt?
    &hooks=`email,redirect` &store=`1` &submitVar=`submit`
    &validate=`first_name:required,last_name:required,zip_code:required,email:email:required,phone:required,choose_username:required,choose_password:required`
    &email=`***n@****.com`
    &emailSubject=`New Dealer Signup`
    &thankYouPage=`1`
]]

<form name="dealer-signup" id="dealer-signup" action="/" method="post">
  <div>
    <label for="first_name">First Name</label>
    <input type="text" id="first_name" name="first_name" placeholder="First Name" required>
  </div>
  <div>
    <label for="last_name">Last Name</label>
    <input type="text" id="last_name" name="last_name" placeholder="Last Name" required>
  </div>
  <div>
    <label for="company_name">Company Name</label>
    <input type="text" id="company_name" name="company_name" placeholder="Company Name" required>
  </div>
  <div>
    <label for="zip_code">Zip Code</label>
    <input type="text" id="zip_code" name="zip_code" required>
  </div>
  <div>
    <label for="email">Email</label>
    <input type="email" id="email" name="email" placeholder="Email" required>
  </div>
  <div>
    <label for="phone">Phone</label>
    <input type="tel" id="phone" name="phone" placeholder="Phone" required>
  </div>
  <div>
    <label for="choose_username">Choose Username</label>
    <input type="text" id="choose_username" name="choose_username" placeholder="Choose Username" required>
  </div>
  <div>
    <label for="choose_password">Choose Password</label>
    <input type="password" id="choose_password" name="choose_password" required>
  </div>
  <div>
    <label for="comments">Comments</label>
    <textarea id="comments" name="comments"></textarea>
  </div>
  <button type="submit" id="submit" name="submit">Submit</button>
</form>

How wrong am I doing this?

I suppose you also need the FormItSaveForm hook.

I updated the code…

[[!FormIt?
    &hooks=`email,redirect,FormItSaveForm` &store=`1` &submitVar=`submit`

Still not saving or emailing. Weird.

Well your code seem to have a lot of additional issues:

The action attribute probably should be action="[[~[[*id]]]]"

Add a value attribute to the button → <button type="submit" id="submit" name="submit" value="1">

I think the name of the property is “emailTo” → &emailTo=***n@****.com`

There is no such property. Do you mean &redirectTo?

Thank you I got it working with your help.

As soon as the mysql server restarts the GROUP BY error will come back.

How do I patch the plugin?

In the pull request on Github (I linked above), there is a tab “Files changed”, that shows the paths of the 2 files that have to be changed and the code changes.

I have applied the patch and so far all is well.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.