Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Wires are mispositioned when using wirable fields within "group" fields

#20

When using the "wirable" option at a sub-field of a "group" field, the wires are mispositioned (it starts very far below the actual starting point).

The same is happening when "wirable" fields are positioned within "list" fields.

Attached you'll find a full demonstration of the bug.

Reported by ingmars (at web) · June 26th, 2009 @ 07:04 PM

State: resolved
Milestone: none

Activity

  1. ingmars (at web)
    ingmars (at web)

    Here's a solution for the mentioned bug (maybe not the most elegant one, but at least it works.)

    The problem was, that the wirable sub fields didn't have a back reference to their containers any more. Therefore, they didn't "know" at what point to stop adding up the top / left offsets and just calculated all the way done to the body element.

    It did work for fields on the first level, but not for sub fields.

    Solution: Just set the options.container property for sub fields of group of list fields as well.

    ===============================================================================

    In the file js/util/inputex/FormContainer-beta.js replace the method renderForm with
    the following two methods:

    /**

    * Render the form
    * @method renderForm
    */
    

    renderForm: function() {

      this.setBackReferenceOnFieldOptionsRecursively(this.options.fields);
    
      var groupParams = {parentEl: this.bodyEl, fields: this.options.fields, legend: this.options.legend, collapsible: this.options.collapsible};
      this.form = new YAHOO.inputEx.Group(groupParams);
    

    },

    setBackReferenceOnFieldOptionsRecursively: function(fieldArray) {

      for(var i = 0 ; i < fieldArray.length ; i++) {
          var inputParams = fieldArray[i].inputParams;
          inputParams.container = this;
    
          // Checking for group sub elements
          if(inputParams.fields && typeof inputParams.fields == 'object') {
              this.setBackReferenceOnFieldOptionsRecursively(inputParams.fields);
          }
    
          // Checking for list sub elements
          if(inputParams.elementType) {
              inputParams.elementType.inputParams.container = this;
    
              // Checking for group elements within list elements
              if(inputParams.elementType.inputParams.fields && typeof inputParams.elementType.inputParams.fields == 'object') {
                  this.setBackReferenceOnFieldOptionsRecursively(inputParams.elementType.inputParams.fields);
              }
          }
      }
    

    },

    ===============================================================================

    July 5th, 2009 @ 07:26 PM

  2. ingmars (at web)
    ingmars (at web)

    Once again, now nicer to read (hopefully!)

    In the file js/util/inputex/FormContainer-beta.js replace the method renderForm with
    the following two methods:

    
       /**
        * Render the form
        * @method renderForm
        */
       renderForm: function() {
          this.setBackReferenceOnFieldOptionsRecursively(this.options.fields);
          
          var groupParams = {parentEl: this.bodyEl, fields: this.options.fields, legend: this.options.legend, collapsible: this.options.collapsible};
          this.form = new YAHOO.inputEx.Group(groupParams);
       },
       
       setBackReferenceOnFieldOptionsRecursively: function(fieldArray) {
          for(var i = 0 ; i < fieldArray.length ; i++) {
              var inputParams = fieldArray[i].inputParams;
              inputParams.container = this;
    
              // Checking for group sub elements
              if(inputParams.fields && typeof inputParams.fields == 'object') {
                  this.setBackReferenceOnFieldOptionsRecursively(inputParams.fields);
              }
    
              // Checking for list sub elements
              if(inputParams.elementType) {
                  inputParams.elementType.inputParams.container = this;
    
                  // Checking for group elements within list elements
                  if(inputParams.elementType.inputParams.fields && typeof inputParams.elementType.inputParams.fields == 'object') {
                      this.setBackReferenceOnFieldOptionsRecursively(inputParams.elementType.inputParams.fields);
                  }
              }
          }
       },
    

    July 5th, 2009 @ 07:27 PM

  3. eric.abouaf (at gmail)
    eric.abouaf (at gmail)
    • State changed from new to resolved

    Thanks a lot for this fix ! This works perfectly.
    It even works for more field than group and list.

    It has been commited on the github repository

    July 5th, 2009 @ 08:11 PM

  4. ingmars (at web)
    ingmars (at web)

    Cool, thanks for committing!

    July 5th, 2009 @ 08:37 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.