added validations to the form

This commit is contained in:
Harry Bomrah 2015-04-30 20:31:43 +08:00
parent fffb546604
commit 2da2e1e502
4 changed files with 11 additions and 5 deletions

View File

@ -6,7 +6,7 @@ class TextMarqueesController < ApplicationController
texts = marquee.marquee_texts.collect do |mqt|
{
"text" => mqt.title,
"url" => mqt.url
"url" => (mqt.url || "")
}
end
{

View File

@ -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 %>
<!-- Input Area -->
@ -41,7 +42,8 @@
<label class="control-label muted"><%= t(:url) %></label>
<div class="controls">
<%= 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) %>
<span class="help-block">Example: http://www.rulingcom.com/</span>
<% end %>
</div>
</div>
@ -59,4 +61,8 @@
<%= link_to t('cancel'), admin_text_marquee_path(@marquee), :class=>"btn" %>
</div>
</div>
</div>
<script type="text/javascript">
var formValidator = new FormValidator($("form.marquee_text_form"));
</script>

View File

@ -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| %>
<fieldset>
<%= render :partial => 'text_form', locals: {f: f} %>
</fieldset>

View File

@ -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| %>
<fieldset>
<%= render :partial => 'text_form', locals: {f: f} %>
</fieldset>