onInvalidField: function()

in web/wp-content/plugins/acf-extended/assets/js/acfe-input.js [1121:1190]


        onInvalidField: function(e, $el) {

            // get field
            var field = acf.getField($(e.target));

            // make sure notice is an error
            if (!field.notice || field.notice.get('type') !== 'error') {
                return;
            }

            // error class
            if (this.get('error_class')) {
                field.notice.$el.addClass(this.get('error_class'));
            }

            // error position
            switch (this.get('error_position')) {

                case 'hide': {
                    field.notice.remove();
                    break;
                }

                case 'below': {

                    if (field.$control().length) {
                        field.notice.$el.insertAfter(field.$control());
                    } else if (field.$inputWrap().length) {
                        field.notice.$el.appendTo(field.$inputWrap());
                    }

                    field.notice.$el.addClass('-below');
                    break;
                }

                case 'group': {

                    // vars
                    var label = acfe.getTextNode(field.$labelWrap().find('label')).trim();
                    var placeholder = field.$('.acf-input-wrap [placeholder!=""]').attr('placeholder');
                    var message = field.notice.$el.text().trim();

                    // remove acf notice
                    field.notice.remove();

                    // try get label
                    if (label && label.length && label !== '*') {
                        message = `${label}: ${message}`;

                        // otherwise placeholder
                    } else if (placeholder && placeholder.length && placeholder !== '') {
                        message = `${placeholder}: ${message}`;

                        // otherwise field name
                    } else {
                        var name = acfe.ucFirst(field.get('name')).replace(/_/g, ' ');
                        message = `${name}: ${message}`;
                    }

                    // append notice error
                    if (this.notice) {
                        this.notice.$el.append(acf.escHtml(`<p>${message}</p>`));
                    }
                    break;

                }

            }

        },