forked from saurabh/orbit4-5
cant select empty value in page parts
This commit is contained in:
parent
f9dcf7db3a
commit
2f58c02ee5
|
@ -35,7 +35,7 @@ var FormValidator = function(form){
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialize = function(){
|
this.initialize = function(){
|
||||||
fv.elements = form.find("*[data-fv-validation]");
|
fv.elements = fv.form.find("*[data-fv-validation]");
|
||||||
_number_of_validators_++;
|
_number_of_validators_++;
|
||||||
_putFieldsValidatorAndMessage();
|
_putFieldsValidatorAndMessage();
|
||||||
_attachSubmitHandler();
|
_attachSubmitHandler();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<div class="btn-group" data-toggle="buttons-radio">
|
<div class="btn-group" data-toggle="buttons-radio">
|
||||||
<label href="#none" class="btn btn-large <%= @subpart.nil? || @subpart.kind == "none" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
<label href="#none" class="btn btn-large <%= @subpart.nil? || @subpart.kind == "none" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
||||||
<%= t("page_part_kinds.none") %>
|
<%= t("page_part_kinds.none") %>
|
||||||
<input type="radio" <%= @subpart.kind == "none" ? "checked" : "" rescue nil %> class="hide" value="none" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
<input type="radio" <%= @subpart.kind == "none" ? "checked" : "" rescue nil %> class="hide widget_type_class" value="none" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
||||||
</label>
|
</label>
|
||||||
<label href="#text" class="btn btn-large <%= @subpart.kind == "text" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
<label href="#text" class="btn btn-large <%= @subpart.kind == "text" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
||||||
<%= t("page_part_kinds.text") %>
|
<%= t("page_part_kinds.text") %>
|
||||||
<input type="radio" class="hide" <%= @subpart.kind == "text" ? "checked" : "" rescue nil %> value="text" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
<input type="radio" class="hide widget_type_class" <%= @subpart.kind == "text" ? "checked" : "" rescue nil %> value="text" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
||||||
</label>
|
</label>
|
||||||
<!-- <label href="#public_r_tag" class="btn btn-large" data-toggle="tab"> -->
|
<!-- <label href="#public_r_tag" class="btn btn-large" data-toggle="tab"> -->
|
||||||
<%#= t("page_part_kinds.public_r_tag") %>
|
<%#= t("page_part_kinds.public_r_tag") %>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<!-- </label> -->
|
<!-- </label> -->
|
||||||
<label href="#module_widget" class="btn btn-large <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
<label href="#module_widget" class="btn btn-large <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
||||||
<%= t("page_part_kinds.module_widget") %>
|
<%= t("page_part_kinds.module_widget") %>
|
||||||
<input type="radio" class="hide" value="module_widget" <%= @subpart.kind == "module_widget" ? "checked" : "" rescue nil %> name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
<input type="radio" class="hide widget_type_class" value="module_widget" <%= @subpart.kind == "module_widget" ? "checked" : "" rescue nil %> name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
||||||
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
<div class="control-group input-content">
|
<div class="control-group input-content">
|
||||||
<%= f.label :module_app_id, t(:module) + " :", class: "control-label muted" %>
|
<%= f.label :module_app_id, t(:module) + " :", class: "control-label muted" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][module]", options_for_select(@modules.map{|m| [m.title,m.key]}, (@subpart.module rescue nil)),{:include_blank => true,"class" => "input-xlarge change module_name"}) %>
|
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][module]", options_for_select(@modules.map{|m| [m.title,m.key]}, (@subpart.module rescue nil)),{:include_blank => true,"class" => "input-xlarge change module_name", data: {"fv-validation" => "custom_not_empty;", "fv-messages" => "Cannot be empty.;"}}) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if @child_page_count > 0 %>
|
<% if @child_page_count > 0 %>
|
||||||
|
@ -88,4 +88,12 @@
|
||||||
$('*[data-toggle=buttons-radio] input[type=radio]').removeAttr("checked");
|
$('*[data-toggle=buttons-radio] input[type=radio]').removeAttr("checked");
|
||||||
$(this).find("input[type=radio]").prop("checked","checked");
|
$(this).find("input[type=radio]").prop("checked","checked");
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var formValidator = new FormValidator($("form.page_part_form_validate"));
|
||||||
|
formValidator.validate_functions.custom_not_empty = function(value){
|
||||||
|
var widget_type = formValidator.form.find("input.widget_type_class:checked").val();
|
||||||
|
widget_type = (typeof widget_type === "undefined" ? "none" : widget_type);
|
||||||
|
return ((widget_type == "module_widget" && value == "") ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
|
@ -4,7 +4,7 @@
|
||||||
<% content_for :page_specific_css do %>
|
<% content_for :page_specific_css do %>
|
||||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
|
<%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms page_part_form_validate"} do |f| %>
|
||||||
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
|
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
|
||||||
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
|
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
|
||||||
<% if OrbitHelper.is_mobile_view %>
|
<% if OrbitHelper.is_mobile_view %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<% content_for :page_specific_css do %>
|
<% content_for :page_specific_css do %>
|
||||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= form_for @part, url: update_sub_part_page_part_path(@subpart), :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
|
<%= form_for @part, url: update_sub_part_page_part_path(@subpart), :remote=>true, html: { class: "form-horizontal main-forms page_part_form_validate"} do |f| %>
|
||||||
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
|
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
|
||||||
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
|
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
|
||||||
<% if OrbitHelper.is_mobile_view %>
|
<% if OrbitHelper.is_mobile_view %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<% content_for :page_specific_css do %>
|
<% content_for :page_specific_css do %>
|
||||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= form_for @part, url: {:action => "create"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
|
<%= form_for @part, url: {:action => "create"}, :remote=>true, html: { class: "form-horizontal main-forms page_part_form_validate"} do |f| %>
|
||||||
<input class="hidden_part_id" id="part_part_id" name="page_part[part_id]" type="hidden" value="<%= @part_number %>">
|
<input class="hidden_part_id" id="part_part_id" name="page_part[part_id]" type="hidden" value="<%= @part_number %>">
|
||||||
<input class="hidden_page_id" id="part_page_id" name="page_part[page_id]" type="hidden" value="<%= @page_id %>">
|
<input class="hidden_page_id" id="part_page_id" name="page_part[page_id]" type="hidden" value="<%= @page_id %>">
|
||||||
<% if OrbitHelper.is_mobile_view %>
|
<% if OrbitHelper.is_mobile_view %>
|
||||||
|
|
Loading…
Reference in New Issue