Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation ajax action returns value with wrong header #490

Open
mediaessenz opened this issue Apr 6, 2023 · 1 comment
Open

Validation ajax action returns value with wrong header #490

mediaessenz opened this issue Apr 6, 2023 · 1 comment
Milestone

Comments

@mediaessenz
Copy link
Contributor

The corresponding TypoScript set Content-Type to application/json:

feManagerValidation = PAGE
feManagerValidation {
  typeNum = 1548935210
  config {
    additionalHeaders.10.header = Content-Type: application/json
    no_cache = 0
    disableAllHeaderCode = 1
    disablePrefixComment = 1
    xhtml_cleaning = 0
    admPanel = 0
    debug = 0
  }

  10 = USER_INT
  10 {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Femanager
    pluginName = Pi1
    vendorName = In2code
    controller = User
    action = validate
    switchableControllerActions.User.1 = validate
    features.requireCHashArgumentForActionArguments = 0
  }
}

The Action due to the usage of return $this->htmlResponse(); returns Content-Typ: text/html; charset=utf-8.

In the end, the browser doesn't get back the right format and a response for an invalid field looks like this:

{"validate":0,"message":"\n\n\t\n\t\tDies ist ein Pflichtfeld\n\t\n\t<br \>\n"}

Therefore not validation appears in the frontent and the console shows this error message:

Error: The called url is not available - if you use TYPO3 in a subfolder, please use config.baseURL in TypoScript
@mediaessenz
Copy link
Contributor Author

Possible solution:

Change the return to:

return $this->jsonResponse();

and remove additionalHeaders.10.header from the TypoScript.

Additional remove all whitespaces from EXT:femanager/Resources/Private/Partials/Misc/ValidationMessages.html

@sbusemann sbusemann added this to the 8.0 milestone Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants