From 2da2e1e502de89ee77a2e3ac8c2809fee44c2ea0 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 30 Apr 2015 20:31:43 +0800 Subject: [PATCH] added validations to the form --- app/controllers/text_marquees_controller.rb | 2 +- app/views/admin/text_marquees/_text_form.html.erb | 10 ++++++++-- app/views/admin/text_marquees/edittext.html.erb | 2 +- app/views/admin/text_marquees/newtext.html.erb | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/text_marquees_controller.rb b/app/controllers/text_marquees_controller.rb index f31b11a..d8dd4bd 100644 --- a/app/controllers/text_marquees_controller.rb +++ b/app/controllers/text_marquees_controller.rb @@ -6,7 +6,7 @@ class TextMarqueesController < ApplicationController texts = marquee.marquee_texts.collect do |mqt| { "text" => mqt.title, - "url" => mqt.url + "url" => (mqt.url || "") } end { diff --git a/app/views/admin/text_marquees/_text_form.html.erb b/app/views/admin/text_marquees/_text_form.html.erb index bcf9de7..5c3be6d 100644 --- a/app/views/admin/text_marquees/_text_form.html.erb +++ b/app/views/admin/text_marquees/_text_form.html.erb @@ -4,6 +4,7 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/bootstrap-fileupload" %> <%= javascript_include_tag "lib/module-area" %> + <%= javascript_include_tag "validator" %> <% end %> @@ -41,7 +42,8 @@
<%= f.fields_for :url_translations do |f| %> - <%= f.text_field locale, class: "input-block-level", placeholder: t(:url), value: (@marquee_text.url_translations[locale] rescue nil) %> + <%= f.text_field locale, class: "input-block-level",data: {"fv-validation" => "url;", "fv-messages" => "Must be a valid url.;"}, placeholder: t(:url), value: (@marquee_text.url_translations[locale] rescue nil) %> + Example: http://www.rulingcom.com/ <% end %>
@@ -59,4 +61,8 @@ <%= link_to t('cancel'), admin_text_marquee_path(@marquee), :class=>"btn" %> - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/admin/text_marquees/edittext.html.erb b/app/views/admin/text_marquees/edittext.html.erb index 2abe884..a41265a 100644 --- a/app/views/admin/text_marquees/edittext.html.erb +++ b/app/views/admin/text_marquees/edittext.html.erb @@ -1,4 +1,4 @@ -<%= form_for @marquee_text, url: admin_text_marquee_updatetext_path(@marquee_text), html: {class: "form-horizontal main-forms"} do |f| %> +<%= form_for @marquee_text, url: admin_text_marquee_updatetext_path(@marquee_text), html: {class: "form-horizontal main-forms marquee_text_form"} do |f| %>
<%= render :partial => 'text_form', locals: {f: f} %>
diff --git a/app/views/admin/text_marquees/newtext.html.erb b/app/views/admin/text_marquees/newtext.html.erb index 197b3f7..1733b34 100644 --- a/app/views/admin/text_marquees/newtext.html.erb +++ b/app/views/admin/text_marquees/newtext.html.erb @@ -1,4 +1,4 @@ -<%= form_for @marquee_text, url: admin_text_marquee_createtext_path(@marquee), html: {class: "form-horizontal main-forms"} do |f| %> +<%= form_for @marquee_text, url: admin_text_marquee_createtext_path(@marquee), html: {class: "form-horizontal main-forms marquee_text_form"} do |f| %>
<%= render :partial => 'text_form', locals: {f: f} %>