Skip to content

Commit

Permalink
gallery-2009.11.17-23 ghinch gallery-form
Browse files Browse the repository at this point in the history
  • Loading branch information
YUI Builder committed Nov 17, 2009
1 parent ab79603 commit b83e7af
Show file tree
Hide file tree
Showing 6 changed files with 467 additions and 149 deletions.
2 changes: 1 addition & 1 deletion src/gallery-form/build.properties
Expand Up @@ -19,5 +19,5 @@ component.jsfiles=form.js, form-field.js, text-field.js, checkbox-field.js, hidd
# NOTE: For a css component, this property is not used/required.

# component.use, component.supersedes, component.optional and component.skinnable are other properties which can be defined
component.requires=node, attribute, widget, io-form, substitute
component.requires=node, widget, io-base
component.builddir=../../tmp
21 changes: 20 additions & 1 deletion src/gallery-form/js/checkbox-field.js
Expand Up @@ -14,7 +14,26 @@ Y.mix(CheckboxField, {
});

Y.extend(CheckboxField, Y.FormField, {
_nodeType : 'checkbox'
_nodeType : 'checkbox',

_getValue : function (val, attrname) {
if (this._fieldNode.get('checked') === true) {
return val;
} else {
return '';
}
},

initializer : function () {
CheckboxField.superclass.initializer.apply(this, arguments);

this.modifyAttr('value', {
getter : function (val, attrName) {
return this._getValue(val, attrName);
},
writeOnce : true
});
}
});

Y.CheckboxField = CheckboxField;
31 changes: 17 additions & 14 deletions src/gallery-form/js/choice-field.js
Expand Up @@ -49,20 +49,24 @@ Y.extend(ChoiceField, Y.FormField, {
if (!Y.Lang.isArray(val)) {
return false;
}

var valid = true;

for (var i=0, l=val.length;i<l;i++) {
if (!Y.Lang.isObject(val[i])) {
return false;
Y.Array.each(val, function(c, i, a) {
if (!Y.Lang.isObject(c)) {
valid = false;
return;
}
if (!val[i].label ||
!Y.Lang.isString(val[i].label) ||
!val[i].value ||
!Y.Lang.isString(val[i].value)) {
return false;
if (!c.label ||
!Y.Lang.isString(c.label) ||
!c.value ||
!Y.Lang.isString(c.value)) {
valid = false;
return;
}
}
});

return true;
return valid;
},

_renderLabelNode : function () {
Expand All @@ -77,16 +81,15 @@ Y.extend(ChoiceField, Y.FormField, {
_renderFieldNode : function () {
var contentBox = this.get('contentBox'),
choices = this.get('choices'),
i=0, l=choices.length,
elLabel, elField;
for(;i<l;i++) {

Y.Array.each(choices, function(c, i, a) {
elLabel = Y.Node.create(FormField.LABEL_TEMPLATE);
contentBox.appendChild(elLabel);

elField = Y.Node.create(FormField.INPUT_TEMPLATE);
contentBox.appendChild(elField);
}
});

this._fieldNode = contentBox.all('input');
},
Expand Down

0 comments on commit b83e7af

Please sign in to comment.