Skip to content

Commit

Permalink
Fix a Checkbox bug, add example definition for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Jul 29, 2011
1 parent 0c6393d commit 110197e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions assets/scaffolds.sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,18 @@
// Symphony adds a hidden field before a checkbox, so field
// may be an area with two elements. The first element will be a
// hidden field, the second will be a checkbox.
if(field.length == 2
&& $(field[1]).attr('type') == 'checkbox'
if(
field.length == 2 && $(field[1]).is(':checkbox')
) {
$(field[1]).attr('checked', (value !== 'no'));
}

// Not all Checkbox fields have the hidden field, so handle that
// case as well
else if(field.is(':checkbox')) {
field.attr('checked', (value !== 'no'));
}

// Input
else {
field.val(value);
Expand Down
19 changes: 19 additions & 0 deletions examples/core.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Date": {
"type": "date"
},
"Name": {
"type": "input"
},
"Categories": {
"type": "select",
"location": "main",
"static_options": "Example 1, Example 2",
"show_column": "no"
},
"Publish": {
"type": "checkbox",
"default_state": "yes",
"description": "Publish this entry?"
}
}

0 comments on commit 110197e

Please sign in to comment.