_manage_community_fields.rhtml
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<h2><%= __('Manage community fields') %></h2>
<% labelled_form_for(:environment, @environment, :url => {:action => 'manage_community_fields'}) do |f| %>
<table id='community_fields_conf'>
  <tr>
    <th><%= _('Field') %></th>
    <th><%= _('Active') %></th>
    <th><%= _('Required') %></th>
    <th><%= _('Display on creation?') %></th>
  </tr>
  <% @community_fields.each do |field| %>
  <tr>
    <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
    <td>
      <%= hidden_field_tag  "community_fields[#{field}][active]", false %>
      <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "$('community_fields[#{field}][required]').disabled=$('community_fields[#{field}][signup]').disabled=!this.checked;" %>
    </td>
    <td>
      <%= hidden_field_tag  "community_fields[#{field}][required]", false %>
      <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "if(this.checked) $('community_fields[#{field}][signup]').checked = true;" %>
    </td>
    <td>
      <%= hidden_field_tag  "community_fields[#{field}][signup]", false %>
      <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "if(!this.checked) $('community_fields[#{field}][required]').checked = false;" %>
    </td>
  </tr>
  <% end %>
</table>
<script type='text/javascript'>
  var trs = $$('#community_fields_conf tr');
  var tr, td2;
  for ( var i=0; tr=trs[i]; i++ ) {
    if ( td2 = tr.getElementsByTagName('td')[1] ) {
      td2.getElementsByTagName('input')[0].onclick();
    }
  }
</script>
<div>
  <% button_bar do %>
    <%= submit_button('save', _('Save changes')) %>
    <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %>
  <% end %>
</div>
<% end %>