Front-end mandatory-validation for radiolist and checkbox list.
This commit is contained in:
@@ -43,7 +43,8 @@
|
||||
value: "@",
|
||||
name: "@",
|
||||
text: "@",
|
||||
onChange: "="
|
||||
required: "=",
|
||||
onChange: "&"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
model: "=",
|
||||
value: "@",
|
||||
name: "@",
|
||||
text: "@"
|
||||
text: "@",
|
||||
required: "="
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
value="{{value}}"
|
||||
ng-model="model.checked"
|
||||
class="umb-form-check__input"
|
||||
ng-required="model.validation.mandatory && !model.value.length"
|
||||
ng-required="required"
|
||||
ng-change="onChange(model)"/>
|
||||
|
||||
<div class="umb-form-check__state umb-form-check__state" aria-hidden="true">
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<input type="radio" name="{{name}}"
|
||||
value="{{value}}"
|
||||
ng-model="model"
|
||||
class="umb-form-check__input" />
|
||||
class="umb-form-check__input"
|
||||
ng-required="required" />
|
||||
|
||||
<div class="umb-form-check__state umb-form-check__state" aria-hidden="true">
|
||||
<div class="umb-form-check__check"></div>
|
||||
|
||||
@@ -71,15 +71,15 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro
|
||||
var index = _.findIndex($scope.model.value,
|
||||
function (v) {
|
||||
return v === item.val;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (item.checked) {
|
||||
//if it doesn't exist in the model, then add it
|
||||
if (index < 0) {
|
||||
$scope.model.value.push(item.val);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//if it exists in the model, then remove it
|
||||
if (index >= 0) {
|
||||
$scope.model.value.splice(index, 1);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<div class="umb-property-editor umb-checkboxlist" ng-controller="Umbraco.PropertyEditors.CheckboxListController">
|
||||
|
||||
<ul class="unstyled">
|
||||
<li ng-repeat="item in selectedItems track by item.key">
|
||||
<umb-checkbox name="{{model.alias}}" value="{{item.key}}" model="item" text="{{item.val}}" on-change="changed(item)"></umb-checkbox>
|
||||
<umb-checkbox name="{{model.alias}}" value="{{item.key}}" model="item" text="{{item.val}}" on-change="changed(item)" required="model.validation.mandatory && !model.value.length"></umb-checkbox>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="umb-property-editor umb-radiobuttons" ng-controller="Umbraco.PropertyEditors.RadioButtonsController">
|
||||
<ul class="unstyled">
|
||||
<li ng-repeat="item in configItems track by item.id">
|
||||
<umb-radiobutton name="{{model.alias}}" value="{{item.id}}" model="model.value" text="{{item.value}}"></umb-radiobutton>
|
||||
<umb-radiobutton name="{{model.alias}}" value="{{item.id}}" model="model.value" text="{{item.value}}" required="model.validation.mandatory && model.value == ''"></umb-radiobutton>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user