Skip to content

ng-django-forms and non classic fields (ace) #178

Description

@adrienbrunet

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions