-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for category specific fields
Some fields are only applicable to a subset of the categories. This commit hides the irrelevant fields using JavaScript and filters them out on the server side.
- Loading branch information
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
|
||
{block content} | ||
{control teamForm} | ||
{/block} | ||
{block scripts} | ||
<script src="{$basePath}/js/form.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
|
||
{block content} | ||
{control teamForm} | ||
{/block} | ||
{block scripts} | ||
<script src="{$basePath}/js/form.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$(function(){ | ||
var conditionalFields = []; | ||
$('[data-applicable-categories]').each(function() { | ||
conditionalFields.push([ | ||
$(this).parents('.form-group'), | ||
JSON.parse(this.getAttribute('data-applicable-categories')) | ||
]); | ||
}); | ||
|
||
var categoryField = $('#frm-teamForm-category'); | ||
|
||
function categoryChanged() { | ||
var category = categoryField.val(); | ||
$.each(conditionalFields, function() { | ||
if (this[1].indexOf(category) === -1) { | ||
$(this[0]).hide(); | ||
} else { | ||
$(this[0]).show(); | ||
} | ||
}); | ||
}; | ||
|
||
categoryField.change(categoryChanged); | ||
categoryChanged(); | ||
}); |