function 'validateForm' not found or invalid function name in call_user_func_array()

Created on 1 December 2023, 12 months ago
Updated 29 April 2024, 7 months ago

Problem/Motivation

Sometimes I have error TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function 'validateForm' not found or invalid function name in call_user_func_array() (line 82 of core/lib/Drupal/Core/Form/FormValidator.php). Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)

We have radix_form_alter in form.inc and $form['#validate'][] = 'validateForm';
'validateForm' function name is not a good choice and it should be with some module/theme prefix.
Also on ajax form we have situation when this form.inc is included on form but after some ajax on validation form this is not included and we have error.

🐛 Bug report
Status

Closed: won't fix

Version

5.0

Component

Code

Created by

🇺🇦Ukraine Kalavan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Kalavan
  • First commit to issue fork.
  • Status changed to Needs review 12 months ago
  • 🇮🇳India viren18febS

    I have resolved the issue & added patch, please review.

  • it's good to have a custom name maybe, not sure if there's a problem with having a generic name within a theme itself, the patch just renames the function

    the Ajax error you are referring to, need more context, could be a drupal error and not a Radix issue, also depends on your implementation

  • Status changed to Closed: won't fix 12 months ago
  • 🇺🇸United States jimconte

    We are running Radix on a site using Layout builder and getting the same error.
    Removing the hook and the function, error goes away.

    This is what I think is happening:

    • Form loads in front end context (Radix)
    • Layout Builder mixes with front end, runs form alter hook from Radix
    • Form builds, adds #validate looking for "validateForm" function
    • Editor edits
    • Edit function called from Layout Builder
    • But Layout Builder runs in Admin context
    • Ajax Form executes in Admin context
    • function does not exist in Admin theme
    • error is thrown
  • Status changed to Active 11 months ago
  • 🇺🇸United States jimconte

    Steps to reproduce:

    • Install Radix as front end theme
    • Enable layout builder
    • Create a Custom Block type with an image
    • Add inline block to any node with Layout builder
    • Add image to block
    • Submit change
    • Error thrown
  • Status changed to Closed: won't fix 7 months ago
Production build 0.71.5 2024