angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

TypeError: Cannot read property 'updateOn' of undefined

Open quietlyconfident opened this issue 11 years ago • 13 comments

On the example page, if I switch from the "simple" example to the "complex key support" example, I get the error message:

screen shot 2015-01-09 at 10 11 37 am

quietlyconfident avatar Jan 09 '15 15:01 quietlyconfident

Yes, I actually noticed this a while ago – thanks for filing the bug. The release version of Angular 1.3 broke support for keys that contain brackets, so while SF correctly writes a'rr[\"l as <input ... ng-model="model['a\'rr[\\"l']">, Angular is failing to parse it. I'll file a bug with Angular and reference this one. This is probably a super crazy edge case, but unless Angular dropped this for performance reasons (which I could definitely understand) this is a bug.

mike-marcacci avatar Jan 09 '15 23:01 mike-marcacci

Thanks. When you do so could you reference that issue here?

quietlyconfident avatar Jan 14 '15 01:01 quietlyconfident

FWIW, I encounter this error in my own application as well, but it goes away if I navigate away and navigate back to the page in question. Whereas, when I fiddle with the test on the example page, the error seems to stay regardless of whether I navigate away and return.

quietlyconfident avatar Jan 16 '15 20:01 quietlyconfident

I am getting this issue while using it within a popover. I have no issues with using any other directives inside the popover. Any thoughts of how to solve this at least temporarily?

stramel avatar Jan 22 '15 20:01 stramel

I am getting this error in my custom decorator:

<div class="schema-form-layout-grid {{form.htmlClass}}">
    <div class="container">
        <div class="row" ng-repeat="row in form.rows">
            <div class="{{col.colTypeClass}}" ng-repeat="col in row.cols">
                <sf-decorator form="col.content"></sf-decorator>
            </div>
        </div>
    </div>
</div>

asadighi avatar Jan 23 '15 18:01 asadighi

Never mind my issue, I realized the error is gone if i use "item in form.items" instead of "row in form.rows" or "col in form.cols".

asadighi avatar Jan 23 '15 20:01 asadighi

This is a weird one. Angular has problems with ngModelOptions, I haven't dug deeply, but leaving the options object undefined seems to trigger this. I have some code in schema form that just populates it with an empty {} just for that sake. So I guess its probably a timing issue, the first digest loop the model options aren't properly defined but the next they are, but that is just a guess.

davidlgj avatar Jan 24 '15 17:01 davidlgj

I got the same error "Cannot read property 'updateOn' of undefined" on my custom decorator. And break the executation. Help me to resolve this.

<div sf-repeaterSimple="form" class="schema-form-repeaterSimple {{form.htmlClass}}"
     ng-model="$$value$$" ng-model-options="form.ngModelOptions" sfRepeaterSimple>
  <h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3>
  <ol class="list-group" ng-model="modelRepeaterSimple" ui-sortable>
    <li class="list-group-item {{form.fieldHtmlClass}}"
        ng-repeat="item in modelRepeaterSimple track by $index">
      <button ng-hide="form.readonly"
              ng-click="deleteFromRepeaterSimple($index)"
              style="position: relative; z-index: 20;"
              type="button" class="close pull-right">
              <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
      </button>
      <sf-decorator ng-init="repeaterSimpleIndex = $index" form="copyWithIndex($index)"></sf-decorator>
    </li>
  </ol>
  <div class="clearfix" style="padding: 15px;">
    <button ng-hide="form.readonly || form.add === null"
            ng-click="appendToRepeaterSimple()"
            type="button"
            class="btn {{ form.style.add || 'btn-default' }} pull-right">
      <i class="glyphicon glyphicon-plus"></i>
      {{ form.add || 'Add'}}
    </button>
  </div>
  <div class="help-block"
       ng-show="(hasError() && errorMessage(schemaError())) || form.description"
       ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div>
</div>

pkpatels avatar Feb 05 '15 17:02 pkpatels

Is there a workaround for this?

lynndylanhurley avatar Feb 16 '15 19:02 lynndylanhurley

@airdrik over in issue #255 seems to have a solution, I haven't been able to confirm it since I'm having trouble reproducing it, but the fix is in the development branch now.

davidlgj avatar Feb 20 '15 14:02 davidlgj

The solution was actually provided by @plong0.
I'd also run into this problem, and had worked around it by adding ngModelOptions: {} fields to any form elements in the items list of another form element, e.g. form elements within fieldset, section, tabs, tabarray, etc. I'll give plong0's solution a try though as it would be nice to clean up some of those items that were only expanded into full objects because they needed that ngModelOptions field set to something.

airdrik avatar Feb 20 '15 14:02 airdrik

Oh sorry, I messed up the name, as @airdrik says the solution came from @plong0.

And yes a more correct solution would be to only add the ngModelOptions attribute to the input if the form has it, but I don't know how to do that in a clean and performant way (i.e. no double $compile)

Another fix is to patch angular so that an undefined ngModelOption doesn't trigger an exception.

davidlgj avatar Feb 20 '15 15:02 davidlgj

Sorry to bring this up again, but I was doing exactly what @asadighi was trying to do and get this error.

The template can iterate down to cell.items and it can display the strings inside, but once I change the text binding from {{cell.items}} to <sf-decorator ng-repeat="cellitem in cell.items" form="cellitem"></sf-decorator> it throws.

How did you workaround that?

vicary avatar Oct 30 '15 10:10 vicary