formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 405 forks source link

Calling "updateInitialValue" on an unitialized field throw a JavaScript error. #662

Open maxime-beguin opened 8 years ago

maxime-beguin commented 8 years ago

Hi,

First of all, thanks for the project.

Trying to use the updateInitialValue method with, at least, one field not initialized, crash with the following JavaScript error : "field.updateInitialValue is not a function".

It appears that the field is not initialized until the "hideExpression" becomes true.

Here is a JSBin example to reproduce the issue : http://jsbin.com/fimotu/edit?html,output

Or you can directly use the hide-fields example.

Thanks.

dariusjb commented 8 years ago

Hi, I have the same exact issue. formly code does the routine of calling the updateInitialValue on all fields, but if by default the field was disabled (using the hideExpression), that routine will go into exception since disabled fields are not properly initialized by formely, it did not wrap them with these formly functions.

Could anyone provide a fix, please?

kentcdodds commented 8 years ago

Hi @dariusjb and @maxime-beguin,

Thanks for reporting this. It needs more investigation and possibly a fix.

Could anyone provide a fix, please?

This is a community project, you could makeapullrequest.com or add a bounty on this issue to motivate someone else to do so.