Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## javascript in application.js
- //for stencil_controller
- function show_category_override() {
- value = document.findElementById('stencil_category').value;
- if value == "NEW CATEGORY -->" {
- document.getElementById('override').display='';
- } else {
- document.getElementById('override').display='none';
- }
- }
- ## controller
- def new
- @stencil = Stencil.new
- @categories = Stencil.categories #array of text
- @categories << "NEW CATEGORY -->"
- end
- ## view
- <p class="content_head">
- Create New Stencil
- </p>
- <% form_for :stencil, :url => {:action => "create"}, :html => {:multipart => true} do |f| -%>
- <p class="content">
- <%= f.label :image, 'stencil image' -%><br/>
- <%= f.file_field :image, :size => 40 -%>
- </p>
- <p class="content">
- <%= f.label :title, 'title' -%><br/>
- <%= f.text_field :title, :size => 40 -%>
- </p>
- <p class="content">
- <%= f.label :category, 'category' -%><br/>
- <%= f.select :category, @categories, {:selected => "Other"}, {:onchange => "show_category_override();"} -%>
- <span id="override" style="display:none;"><%= text_field_tag :category_override, nil, :size => 20 -%></span>
- </p>
- <p class="content">
- <%= submit_tag "Create Stencil" -%>
- </p>
- <% end -%>
Add Comment
Please, Sign In to add comment