-
Notifications
You must be signed in to change notification settings - Fork 556
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
Error "passing 'type' property is not allowed when 'template' is set" even when template set to null #2121
Comments
I have downgraded to 5.5.7 for the time being and the fields in my forms are showing again. |
is there any relevant reason that prevent you to remove entirely |
The json is generated programmatically using Spring on the server side. So if the template is not set the json is generated as The problem, starting with ngx-formly 5.5.8, is that the code no longer checks if the template is set (despite what the error message says): it now only checks to see if the template attribute exists. In my proposed fix ngx-formly would once again check to see if the template were set. |
I know this is after the fact but you should also consider configuring your
json serializer to not add the value ( donut is undefined ) instead of
serializing attribute = null. It saves on response download performance
and makes json data easier to read.
That being said our lib should definitely make sure it exists and is set.
…On Wed, Mar 4, 2020, 8:42 AM Abdellatif Ait boudad ***@***.***> wrote:
Closed #2121 <#2121> via
#2126 <#2126>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2121?email_source=notifications&email_token=ADB4XNNJCHH3XSMNMLCJ5R3RFZSFVA5CNFSM4K6NUTLKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOXCK3AQQ#event-3096817730>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADB4XNOZI7EK5234XF43D6TRFZSFVANCNFSM4K6NUTLA>
.
|
This issue has been fixed and released as part of v5.5.14 release. as @kenisteward suggested It would be better to avoid passing unnecessary data 😄! |
Yes! I did!
Description
A clear and concise description of what the bug is.
In ngx-formly version 4 I had been emitting field json like this:
This worked fine, but this was broken in commit 71d343e, where the check was previously:
if (field.template) ...
So if the template were null, everything was fine.
But in this commit the check was changed to:
if (field.hasOwnProperty('template') ...)
which is true even if the value of "template" is null.
So now I'm getting the error:
NgxFormly: passing 'type' property is not allowed when 'template' is set.
In my opinion the error is not really correct ... if "template" is null it is not actually being "set" to anything.
Is there a reason you are no longer checking to see if the template has been set?
I don't know about the larger issue you were trying to fix, but if you have no objection I could do a pull request with line 77 changed to:
(field.hasOwnProperty('template') && field.template)
Minimal Reproduction
In the stackblitz note that the text input and select question have disappeared because I set
template: null
for both of them:https://stackblitz.com/edit/ngx-formly-ui-bootstrap-bsjvxi?file=src/app/app.component.ts
Your Environment
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: