Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    1
    Vote Rating
    0
    tixelated is on a distinguished road

      0  

    Default Ext.form.Fieldset inconsistent setInstructions behavior

    Ext.form.Fieldset inconsistent setInstructions behavior


    It's possible to set fieldset instructions to '' prior to form rendering and hide the instructions element entirely. Setting instructions to '' after render causes those elements to be created and displayed (as empty grey divs by default.)

    Suggestion:
    - make the empty string ('') behavior consistent pre- and post-render
    - provide a mechanism - either a new method, or passing undefined, null, or false to setInstructions - clear the instructions text and remove its element entirely

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Code:
    Ext.override(Ext.form.FieldSet, {
        setInstructions: function(instructions, removeEmpty) {
            removeEmpty = removeEmpty || false;
            
            if (this.rendered) {
                if (this.instructionsEl && instructions.length == 0 && removeEmpty) {
                    Ext.destroy(this.instructionsEl);
                    delete this.instructionsEl;
                } else if (!this.instructionsEl) {
                    this.instructionsEl = this.el.createChild({
                        cls: this.componentCls + '-instructions'
                    });
                }
                
                if (this.instructionsEl) {
                    this.instructionsEl.setHTML(instructions);
                }
            } else {
                this.instructions = instructions;
            }
            return this;
        }
    });
    This override adds a new parameter for you. Not everyone would want to remove it for whatever reason but if you set that second param to true it will remove the EL if the string is empty. If you want the default to be true then just change the line

    Code:
    removeEmpty = removeEmpty || false;
    to

    Code:
    removeEmpty = removeEmpty || true;
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread