how to best determine original type option?

how to best determine original type option?

loukinglouking Posts: 228Questions: 44Answers: 0

I have a special button which shows a create form, but with all fields hidden. Once the form is dismissed, I need to set the correct show/hide for each field, based on the original field type (checking type === "hidden"). I have the following code, as I was not able to see any api which would help, but maybe I missed something.

Is there a better way?

This code is currently executed when the form is displayed (after hiding all the fields and displaying special purpose "create" text).

                    // show appropriate fields again after the form closes, based on original option
                    config.editor.one('submitComplete preClose', function(e) {
                        config.editor.show();
                        var fields = config.editor.order();
                        for (var i=0; i<fields.length; i++) {
                            var field = fields[i];
                            // warning: using editor internals, not from API
                            if (config.editor.s.fields[field].s.opts.type === "hidden") {
                                config.editor.field(field).hide();
                            }
                        }
                    })

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 9,780Questions: 0Answers: 1,619
    Answer ✓

    Yep, that looks good,

    Colin

Sign In or Register to comment.