Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adrienbrunet opened this issue Jul 7, 2015 · 2 comments
Open

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

adrienbrunet opened this issue Jul 7, 2015 · 2 comments

Comments

@adrienbrunet
Copy link
Collaborator

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?

@adrienbrunet
Copy link
Collaborator Author

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.

@jrief
Copy link
Owner

jrief commented Oct 22, 2017

Please retry with django-angular-2.0, since I can't reproduce this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants