Cleaned up the forum form
This commit is contained in:
@@ -2,6 +2,8 @@ class ForumsController < ApplicationController
|
|||||||
load_and_authorize_resource :category
|
load_and_authorize_resource :category
|
||||||
load_and_authorize_resource :forum, :through => :category, :shallow => true
|
load_and_authorize_resource :forum, :through => :category, :shallow => true
|
||||||
|
|
||||||
|
before_filter :check_for_cancel
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @forum.save
|
if @forum.save
|
||||||
flash[:notice] = "Forum was successfully created."
|
flash[:notice] = "Forum was successfully created."
|
||||||
@@ -24,4 +26,10 @@ class ForumsController < ApplicationController
|
|||||||
redirect_to forums_url
|
redirect_to forums_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_for_cancel
|
||||||
|
if params[:commit] == 'cancel'
|
||||||
|
redirect_to @forum.nil? ? forum_path(@forum) : forums_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -8,51 +8,23 @@
|
|||||||
<% if @forum.errors.any? %>
|
<% if @forum.errors.any? %>
|
||||||
<% flash.now[:error] = @forum.errors.full_messages.join(', and ') %>
|
<% flash.now[:error] = @forum.errors.full_messages.join(', and ') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="fieldset">
|
<%= f.label :category_id %>
|
||||||
<span class="label indent smaller">
|
|
||||||
<%= f.label :category_id %><br />
|
|
||||||
<small>(Required)</small>
|
|
||||||
</span>
|
|
||||||
<span class="input indent smaller">
|
|
||||||
<%= f.collection_select :category_id, Category.all, :id, :title %>
|
<%= f.collection_select :category_id, Category.all, :id, :title %>
|
||||||
</span>
|
<%= f.label :title %>
|
||||||
<div class="clear"></div>
|
<%= f.text_field :title, :style => "width:98%" %>
|
||||||
</div>
|
|
||||||
<div class="fieldset">
|
|
||||||
<span class="label indent smaller">
|
|
||||||
<%= f.label :title %><br />
|
|
||||||
<small>(Required)</small>
|
|
||||||
</span>
|
|
||||||
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<div class="fieldset">
|
|
||||||
<span class="label indent smaller">
|
|
||||||
<%= f.label :description %><br />
|
<%= f.label :description %><br />
|
||||||
<small>(Required)</small>
|
<%= f.text_area :description, :style => "width:98%", :rows => 5 %>
|
||||||
</span>
|
|
||||||
<span class="input indent smaller"><%= f.text_area :description, :cols => 60, :rows => 5 %></span>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<div class="fieldset">
|
|
||||||
<span class="label indent smaller">
|
|
||||||
<%= f.label :position %>
|
<%= f.label :position %>
|
||||||
</span>
|
<%= f.text_field :position %>
|
||||||
<span class="input indent smaller"><%= f.text_field :position %></span>
|
<br/>
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<div class="fieldset">
|
|
||||||
<span class="label indent smaller"></span>
|
|
||||||
<span class="input indent smaller">
|
|
||||||
<%= f.check_box :state %>
|
|
||||||
<%= f.label :state %>
|
<%= f.label :state %>
|
||||||
</span>
|
<%= f.check_box :state %>
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="module_footer">
|
<div class="module_footer">
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", @forum.nil? ? forum_path(@forum) : forums_path %></span>
|
<span class="input">
|
||||||
|
<%= f.submit "Submit", :class =>"btn btn-primary"%>
|
||||||
|
<%= button_tag "Cancel", :confirm => 'Are you sure? Any changes will be lost.', :class => 'btn', :type => 'submit', :name => 'commit', :value => 'cancel' %>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user