aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-11-17 12:09:13 +0000
committerGareth Rees <gareth@mysociety.org>2014-11-17 12:09:13 +0000
commit0909d9ed213de885c9a18b759d3ccbcc3e81ce85 (patch)
tree3530b407972ce2eeb34b45bbda3d87eab7690a54
parente09f967869bc53751a98bfe2cd88d81feca1423f (diff)
Disable rather than hide form fields that can’t be modified
Not clear to the user why the form field is sometimes present and sometimes not present. The Category tag field may only be modified if authorities have not yet been assigned to the Category. This commit explains this and disables the field if this is true.
-rw-r--r--app/views/admin_public_body_categories/_form.html.erb25
1 files changed, 16 insertions, 9 deletions
diff --git a/app/views/admin_public_body_categories/_form.html.erb b/app/views/admin_public_body_categories/_form.html.erb
index b0778d371..1f033ac9b 100644
--- a/app/views/admin_public_body_categories/_form.html.erb
+++ b/app/views/admin_public_body_categories/_form.html.erb
@@ -44,16 +44,23 @@ end
</div>
</div>
-<% if PublicBody.find_by_tag(@category.category_tag).count == 0 or @category.errors.messages.keys.include?(:category_tag) %>
- <h3>Common Fields</h3>
+<h3>Common Fields</h3>
- <div class="control-group">
- <label for="public_body_category_category_tag" class="control-label">Category tag</label>
- <div class="controls">
- <%= f.text_field :category_tag, :class => "span4" %>
- </div>
- </div>
-<% end %>
+<div class="control-group">
+ <label for="public_body_category_category_tag" class="control-label">Category tag</label>
+ <div class="controls">
+ <% if PublicBody.find_by_tag(@category.category_tag).count == 0 or
+ @category.errors.messages.keys.include?(:category_tag) %>
+ <%= f.text_field :category_tag, :class => "span4" %>
+ <% else %>
+ <%= f.text_field :category_tag, :class => "span4", :disabled => true %>
+ <span class="help-block">
+ This Category already has authorities assigned to it so the tags
+ cannot be modified.
+ </span>
+ <% end %>
+ </div>
+</div>
<h3>Headings</h3>
<div class="control-group">