validate error

This commit is contained in:
Aung Myo
2017-06-13 12:04:55 +06:30
parent 9e4c8cef68
commit ee54f1cdd3
6 changed files with 29 additions and 42 deletions

View File

@@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController
#@crm_customers = Customer.all
@crm_customer = Customer.new
# puts @crm_customer.valid?
if flash["errors"]
@crm_customer.valid?
end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -104,7 +104,9 @@ class Crm::CustomersController < BaseCrmController
else
if params[:sale_id]
flash[:errors] = @crm_customers.errors
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else
flash[:errors] = @crm_customers.errors
format.html { redirect_to crm_customers_path}
@@ -148,7 +150,8 @@ end
else
format.html { render :index }
flash[:errors] = @crm_customers.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end

View File

@@ -24,12 +24,10 @@ class Origami::CustomersController < BaseOrigamiController
end
# @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2)
@crm_customer = Customer.new
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
# puts "Errrrrrrrrrrrrrrrrr"
# puts @crm_customer.valid?
if flash["errors"]
@crm_customer.valid?
end
respond_to do |format|

View File

@@ -75,9 +75,7 @@
<div class="form-group">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["name"] %></span>
<% end -%>
</div>
<div class="form-group">
@@ -85,16 +83,12 @@
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["contact_no"] %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["email"] %></span>
<% end -%>
</div>
<div class="form-group">
@@ -110,9 +104,7 @@
<%= member.name %></option>
<%end %>
</select>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["member_group_id"] %></span>
<% end -%>
</div>

View File

@@ -19,7 +19,10 @@
<% flash.each do |type, message| %>
<div class="alert-danger fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%= message %>
<% if !flash["errors"]%>
<%=message%>
<% end %>
</div>
<% end %>
<%= yield %>

View File

@@ -17,10 +17,13 @@
<%= render 'layouts/header_orgiami' %>
<div class="container-fluid">
<% flash.each do |type, message| %>
<div class="alert fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%= message %>
</div>
<% if !flash["errors"]%>
<div class="alert fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%=message%>
</div>
<% end %>
<% end %>
<%= yield %>

View File

@@ -78,25 +78,17 @@
<div class="form-group">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["name"] %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["contact_no"] %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["email"] %></span>
<% end -%>
<%= f.input :email, :class => "form-control col-md-6 email" %>
</div>
<div class="form-group">
@@ -111,11 +103,7 @@
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
<% if flash[:errors] && !flash[:errors].empty? then -%>
<span style="color:red"><%= flash[:errors]["member_group_id"] %></span>
<% end -%>
</select>
</div>
<div class="form-group">