Skip to content

Commit

Permalink
Fixes on inputex plugin (break! : require latest changes from inputex!)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericabouaf committed Aug 26, 2010
1 parent 79a2c38 commit f68627e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 33 deletions.
35 changes: 3 additions & 32 deletions plugins/inputex/js/FormContainer.js
Expand Up @@ -68,11 +68,12 @@ YAHOO.lang.extend(WireIt.FormContainer, WireIt.Container, {
* @method renderForm
*/
renderForm: function() {
this.setBackReferenceOnFieldOptionsRecursively(this.fields);


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

this.form.setContainer(this);

// Redraw all wires when the form is collapsed
if(this.form.legend) {
YAHOO.util.Event.addListener(this.form.legend, 'click', function() {
Expand All @@ -99,36 +100,6 @@ YAHOO.lang.extend(WireIt.FormContainer, WireIt.Container, {
}
},

/**
* When creating wirable input fields, the field configuration must have a reference to the current container (this is used for positionning).
* For complex fields (like object or list), the reference is set recursively AFTER the field creation.
* @method setBackReferenceOnFieldOptionsRecursively
*/
setBackReferenceOnFieldOptionsRecursively: function(fieldArray, container) {
if (YAHOO.lang.isUndefined(container))
container = this;

for(var i = 0 ; i < fieldArray.length ; i++) {
var inputParams = fieldArray[i];
inputParams.container = container;

// 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.container = container;

// Checking for group elements within list elements
if(inputParams.elementType.fields && typeof inputParams.elementType.fields == 'object') {
this.setBackReferenceOnFieldOptionsRecursively(inputParams.elementType.fields);
}
}
}
},

/**
* @method getValue
*/
Expand Down
25 changes: 24 additions & 1 deletion plugins/inputex/js/WirableField.js
Expand Up @@ -30,7 +30,7 @@ lang.extend(inputEx.Field, inputEx.BaseField, {

this.options.wirable = lang.isUndefined(options.wirable) ? false : options.wirable;
this.options.container = options.container;
options.container = null;
//options.container = null;
},

/**
Expand Down Expand Up @@ -74,6 +74,29 @@ lang.extend(inputEx.Field, inputEx.BaseField, {
this.terminal.eventRemoveWire.subscribe(this.onRemoveWire, this, true);
},

/**
* Set the container for this field
*/
setContainer: function(container) {
this.options.container = container;
if(this.terminal) {
this.terminal.container = container;
if( WireIt.indexOf(this.terminal, container.terminals) == -1 ) {
container.terminals.push(this.terminal);
}
}
},

/**
* also change the terminal name when changing the field name
*/
setFieldName: function(name) {
if(this.terminal) {
this.terminal.name = name;
this.terminal.el.title = name;
}
},

/**
* Remove the input wired state on the
* @method onAddWire
Expand Down

0 comments on commit f68627e

Please sign in to comment.