ng-admin icon indicating copy to clipboard operation
ng-admin copied to clipboard

Duplicate id on embedded list fields

Open Phocea opened this issue 8 years ago • 0 comments

Hello,

While writing some Selenium test I realised then when ng-admin is unwrappring an embedded-list type it is always using the configured field name to attribute the id value in the DOM. This results in duplicate id name in the DOM.

So for instance for an embedded list returning a key field we ene dup with a dom like like :

<div id="row-key" class="form-field form-group has-feedback ng-scope" ng-class="getFieldValidationClass()">
    <label for="key" class="col-sm-2 control-label ng-binding">
        Key<!-- ngIf: field.validation().required --><span ng-if="field.validation().required" class="ng-scope">&nbsp;*</span><!-- end ngIf: field.validation().required -->&nbsp;
    </label>
    <div ng-class="getCssClasses(entry)" class="ng-admin-field-key ng-admin-type-string col-sm-10 col-md-8 col-lg-7">
    <ma-input-field field="::field" value="value" class="ng-isolate-scope"><input type="text" ng-attr-step="{{ step }}" ng-model="value" id="key" name="key" class="form-control ng-pristine ng-untouched ng-invalid ng-invalid-required ng-valid-pattern ng-valid-minlength ng-valid-maxlength" ng-required="v.required" ng-minlength="0" ng-maxlength="99999" required="required"></ma-input-field>
    <span ng-show="fieldHasValidation()" class="glyphicon form-control-feedback ng-hide glyphicon-remove" ng-class="fieldIsValid() ? 'glyphicon-ok' : 'glyphicon-remove'"></span>
</div>
</div>

Where id="row-key" is assigned by the ma-field directive (as far as I can tell), and then the <input id="key"). if there are more than one embedded item (so several keys), then you end up with as many time that block in the DOM. There should be a way to send the index inside the directive to be used for the id name assignation.

Phocea avatar Mar 16 '16 15:03 Phocea