1

This is an AngularJS application (1.2.16). I browse to a dialog to edit some item. One of the controls is a multi-SELECT with the following visible values:

incident
work order

These visible values correspond to the following data values:

INCIDENT
WORK_ORDER

This is done through using the ng-options=" ... as ... for ... in ... " pattern, using an enumeration:

var FlexFieldSubjectTypeEnum = {
    INCIDENT:{name:"INCIDENT", description:"incident"},
    WORK_ORDER:{name:"WORK_ORDER", description:"work order"}
}

If have a form pretty much as follows:

<form ng-submit="save(formName)" name="formName" class="form-horizontal">

  ...

    <div class="control-group">
        <label class="control-label">Subject type:</label>
        <div class="controls">
            <select name="subjectType"
                ng-options="type.name as type.description for type in getEnumAsArray('FlexFieldSubjectTypeEnum') | orderBy:'name'"
                ng-model="entity.subjectType"
                required></select>
        </div>
    </div>

Now, if the dialog loads the item ($scope.entity) from the backend and entity.subjectType is set to the first item in the list, the form validation marks it as unset. I have many other dialogs with similar constructs and have not seen this problem anywhere else.

enter image description here

If the item returned from the backend points to the second item (WORK_ORDER), this is nicely represented in the SELECT ("work order") and there is no validation error.

The problem does exist equally when using required or ng-required="true".

The problem does not exist if I remove the required attribute, but then the field also suddenly becomes optional, which is not what I wanted.

Your help much appreciated!

2
  • is your use of ng=options just a typo here? or is that actually how you have it in your code? Commented Apr 15, 2014 at 7:17
  • It was a typo indeed, I corrected it. Commented Apr 15, 2014 at 15:09

1 Answer 1

1

Almost a month later, with meanwhile an upgrade from Bootstrap v2.2.2 to v3.1.1 the problem disappeared.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.