kentcdodds' comments got me moving in the right direction and able to find enough pieces in the docs to make something work. In my most immediate task I was needing a radio option to get removed from the model when disabled, and I ended up unchecking it too. I did this by extending the radio
input type and adding a link
function for access to scope
and the element
. Below is something along the lines of what it looks like:
app.config(['formlyConfigProvider', function (formlyConfigProvider) {
formlyConfigProvider.setType({
name: 'liveDisableRadio',
extends: 'radio',
link: function (scope, element) {
scope.$watch('to.disabled', function (is_disabled) {
if (is_disabled) {
delete scope.model[scope.options.key];
element.find(':radio:checked').prop('checked', false).trigger('change');
}
});
}
});
}])