<div class="modal" tabindex="-1" role="dialog" aria-hidden="true">
    <form class="form-sport" name="form.teamForm" ng-submit="submit()" novalidate>
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h3 class="modal-title">Add Team</h3>
                </div>
                <div class="modal-body form">
                    <div class="form-group" ng-class="{ 'has-error': form.teamForm.name.$dirty && form.teamForm.name.$invalid }">
                        <label class="control-label" for="name">Name</label>
                        <div class="">
                            <input id="name" name="name" ng-model="fields.name" ng-change="slugify()" type="text" class="form-control" required>
                        </div>
                    </div>
                    <div class="form-group" ng-class="{ 'has-error': form.teamForm.shortName.$dirty && form.teamForm.shortName.$invalid }">
                        <label class="control-label" for="shortName">Short Name</label>
                        <div class="">
                            <input id="name" name="shortName" ng-model="fields.shortName" ng-change="slugify()" type="text" class="form-control" required>
                        </div>
                    </div>
                    <!-- Text input-->
                    <div class="form-group" ng-class="{ 'has-error': form.teamForm.slug.$dirty && form.teamForm.slug.$invalid }">
                        <label class="control-label" for="slug">Slug</label>
                        <div class="">
                            <input id="slug" name="slug" ng-model="fields.slug" type="text" class="form-control" required fsa-slugify>
                        </div>
                    </div>
                    <div class="form-group" ng-class="{ 'has-error': form.teamForm.sport.$dirty && form.teamForm.sport.$invalid }">
                        <label class="control-label" for="name">Sport</label>
                        <div class="">
                            <ui-select ng-model="fields.sport" theme="selectize" ng-required="true" on-select="queryLeagues($item)">
                                <ui-select-match placeholder="Please select...">{{$select.selected.name}}</ui-select-match>
                                <ui-select-choices repeat="sport in sports.items | filter: $select.search track by sport.id">
                                    <span ng-bind-html="sport.name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                        </div>
                    </div>
                    <div class="form-group" ng-class="{ 'has-error': form.teamForm.league.$dirty && form.teamForm.league.$invalid }">
                        <label class="control-label" for="name">League </label>
                        <span class="text-primary fa fa-question-circle" data-title="Please select the Sport first before selecting the League" data-placement="right" bs-tooltip></span>
                        <div class="">
                            <ui-select ng-model="fields.league" theme="selectize" ng-required="true" on-select="queryGroups($item)" ng-disabled="fields.sport.id == 0 || fields.sport.id == null">
                                <ui-select-match placeholder="Please select...">{{$select.selected.name}}</ui-select-match>
                                <ui-select-choices repeat="league in leagues.items | filter: $select.search track by league.id">
                                    <span ng-bind-html="league.name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                        </div>
                    </div>
                    <div class="form-group" ng-class="{ 'has-error': form.groupForm.group.$dirty && form.groupForm.group.$invalid }">
                        <label class="control-label" for="name">Group </label>
                        <span class="text-primary fa fa-question-circle" data-title="Please select the League first before selecting the Group" data-placement="right" bs-tooltip></span>
                        <div class="">
                            <ui-select ng-model="fields.group" theme="selectize" ng-required="true" ng-disabled="fields.league.id == 0 || fields.league.id == null">
                                <ui-select-match placeholder="Please select...">{{$select.selected.name}}</ui-select-match>
                                <ui-select-choices repeat="group in groups.items | filter: $select.search track by group.id">
                                    <span ng-bind-html="group.name | highlight: $select.search"></span>
                                </ui-select-choices>
                            </ui-select>
                        </div>
                    </div>
                    <!-- Text input-->
                    <div class="form-group">
                        <label class="control-label" for="description">Description</label>
                        <div class="">
                            <textarea id="description" name="description" ng-model="fields.description" class="form-control" rows="10"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button id="submit" name="submit" class="btn btn-labeled btn-primary" ng-disabled="form.teamForm.$invalid || isSubmitted"><span class="btn-label"><i class="fa fa-upload"></i></span> Submit</button>
                    <button class="btn btn-default btn-labeled" type="button" ng-click="modalAddActions.hide()"><span class="btn-label"><i class="fa fa-times"></i></span> Cancel</button>
                </div>
            </div>
        </div>
    </form>
</div>