<% ProjectSection.order(:lft).each do |section| %> <% padding = 2 + section.ancestors.size * 1.5 %> <% end %> <%= hidden_field_tag('custom_field[section_ids][]', '') %>

<%= javascript_tag do %> $('#custom_field_sections_all').bind('change', function() { if (this.checked) { $('#custom_field_is_for_all').removeAttr('disabled'); $('#custom_field_project_ids input').removeAttr('disabled'); } }); $('#custom_field_sections_some').bind('change', function() { if (this.checked) { $('#custom_field_is_for_all').attr('disabled','disabled'); $('#custom_field_project_ids input').attr('disabled','disabled'); } }); $(document).ready(function() { if ($('#custom_field_is_for_all').is(':checked')) { $('#custom_field_section_ids input').attr('disabled','disabled'); } if ($('#custom_field_sections_some').is(':checked')) { $('#custom_field_is_for_all').attr('disabled','disabled'); $('#custom_field_project_ids input').attr('disabled','disabled'); } $('#custom_field_is_for_all').bind('change', function() { if (this.checked) { $('#custom_field_section_ids input').attr('disabled','disabled'); } else { $('#custom_field_section_ids input').removeAttr('disabled'); } }); }); <% end %>