django-angular
django-angular copied to clipboard
ng-django-forms and non classic fields (ace)
Hi, I'm using ace
with django-angular and I'm facing a problem. The field generated is a div
and I get "Unknow field type" from that piece of code in ng-django-forms. (obviously)
return {
restrict: 'A',
// make sure this directive is applied after angular built-in one
priority: 1,
require: ['ngModel', '^?form'],
link: function(scope, element, attrs, ctrls) {
var field = angular.isElement(element) ? element[0] : null;
var modelCtrl = ctrls[0], formCtrl = ctrls[1] || null;
if (!field || !formCtrl)
return;
switch (field.tagName) {
case 'INPUT':
restoreInputField(modelCtrl, field);
break;
case 'SELECT':
restoreSelectOptions(modelCtrl, field);
break;
case 'TEXTAREA':
restoreTextArea(modelCtrl, field);
break;
default:
console.log('Unknown field type');
break;
}
// restore the form's pristine state
formCtrl.$setPristine();
}
};
As it's corner case just for me, should I just patch this or should we provide a way to handle such cases?
Hey, right now, I've monkey patch this code to add a 'DIV' case with some other stuff. But it's bad. We should provide a way to enable people to add custom field handling without monkey patching the ng-django-forms.js. Do you have any ideas/guidelines how to implement it? I want to do it but I'm not sure how I should start this.
Please retry with django-angular-2.0, since I can't reproduce this.