-
Notifications
You must be signed in to change notification settings - Fork 107
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
Field names missing in Model->getField, causing corrupt Exception message #1704
Comments
I have already seen |
@ibelar can you please look at the JS issue? It seems something is not escaped properly or deescaped/evaluated twice. |
More background @ibelar : For me I get the |
@mkrecek234 can you identify which atk4/ui commit started producing this issue? |
This is likely du to Data\Field error and badly formatted ValidationException throw when see: https://github.com/atk4/data/blob/develop/src/Field.php#L282 Perhaps a regular exception should be thrown when $name property is null. Otherwise the ValidationException will try to execute this javascript expression : Which end up in showing the error message above because of the missing field name. @mkrecek234 : Thanks for pointing out the error form2.php error. I will issue a fix for it. When you see this error, please check for Exception within your model. |
iso cannot be empty because of the model definition the main issue is the JS escaping |
@ibelar By removing the form->save() in the sample form2.php you circumvent this bug. There is an issue saving the form. We should keep real form-> save samples in our demos to demonstrate (and also have real life tests). Can you please check? In fact, this is a new bug that came with the last develop updates. |
@mvorisek @ibelar I found the reason for my issue: The The Exception however is not properly shown, but then the above Javascript Error is shown only. Can you check how to make sure that thrown Exception are properly displayed and not with the unrecognized expressions? |
The error message shown in form2.php happen because there is an exception thrown during the validation process. This Exception is later caught within
What is happening is that $val->errors does not contains any field name, thus generating a bad Fomantic add prompt instruction using an empty field name. The add prompt generated is: When running this instruction return by the server, Fomantic throw an exception, because of badly formatted add prompt message, which is catch by apiService and display within a modal. This error has nothing to do with Javascript, it simply catch a badly formatted add prompt message. I think to correctly fix this, there should be a distinction between a real validation exception and an regular exception throw within the validate method. And I think this should be resolve on the Atk4\Data side. @mvorisek |
we have to throw an exception uniformly with other validation exceptions, not sure what you mean exactly, please submit a PR if you think something behave wrongly |
@mvorisek @ibelar I investigated this further. The issue indeed is that the field name is empty for all fields (short_name though is set) coming from this function: https://github.com/atk4/data/blob/975b27f4de756118860da069ffff103633cc7f3a/src/Persistence.php#L159 With the missing name though, any validation failure will also miss the field name, which ultimately creates the JsExpression error. @mvorisek may be you have an idea how to correct the |
@mkrecek234 thanks for envestigation, let me know which array, eg. what do you expect exactly on which line, I think I can help quickly then ;-) |
@mvorisek on the line under the link above, |
I belive only short_name should be used and all other names should ideally throw an exception (we can unset easily, then it will emit an undefined warning due special trait from atk4/core) :) |
Your take @mvorisek - the missing name leads to
|
In recent develop, example
demos/form/form2.php
don't work:cannot be empty, norcannot it be changedJavascript Error Syntax error, unrecognized expression: #
The second form throws error
Atk4\Ui\Exception: Callback requested, but never reached. You may be missing some arguments in request URL.
on save.The text was updated successfully, but these errors were encountered: