Skip to content
Browse files

Need to revert suppot for required fields: :(

 - does not work in modals
 - not consistent accross field types (string only)
 - may not be welcomed on complex BO with dynamic (cross fields) validations fields
 - not consistent accross error types

Sorry :(

Revert "added support for required fields"

This reverts commit 6e56341.
  • Loading branch information...
1 parent 1102806 commit 7cff5b1875fb21bae3b9dedac3f71eeeffae9dbc @bbenezech bbenezech committed Aug 28, 2012
View
1 .gitignore
@@ -29,4 +29,3 @@ tmp/**/*
.idea/*.xml
.sass-cache
nbproject
-.DS_Store
View
14 app/assets/stylesheets/rails_admin/base/theming.css.scss
@@ -35,14 +35,14 @@ body.rails_admin {
.control-group .hidden_type {
display:none;
}
-
+
legend {
cursor:pointer;
i {
vertical-align: inherit !important;
}
}
-
+
&.denser {
.controls .nav {
margin-bottom:5px;
@@ -67,12 +67,6 @@ body.rails_admin {
.control-group {
margin: 0px;
padding-top:15px;
-
- &.required {
- .control-label {
- font-weight:bold;
- }
- }
}
.control-label {
width:145px;
@@ -81,7 +75,7 @@ body.rails_admin {
margin-bottom:0px;
}
}
-
+
/* We want input size to be used, unfixate input width */
input, textarea {
width:auto;
@@ -101,7 +95,7 @@ body.rails_admin {
&:hover>.remove_nested_fields {
display:block;
}
-
+
border-left:5px solid $blue;
padding-left:5px;
fieldset {
View
8 app/helpers/rails_admin/form_builder.rb
@@ -14,11 +14,11 @@ def generate(options = {})
if options[:nested_in]
action = :nested
elsif @template.request.format == 'text/javascript'
- action = :modal
+ action = :modal
else
action = options[:action]
end
-
+
groups = options[:model_config].send(action).with(:form => self, :object => @object, :view => @template).visible_groups
object_infos +
@@ -45,13 +45,13 @@ def field_wrapper_for field, nested_in
# do not show nested field if the target is the origin
unless field.inverse_of.presence && field.inverse_of == nested_in &&
@template.instance_variable_get(:@model_config).abstract_model == field.associated_model_config.abstract_model
- @template.content_tag(:div, :class => "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?} #{'required' if field.required?}", :id => "#{dom_id(field)}_field") do
+ @template.content_tag(:div, :class => "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => "#{dom_id(field)}_field") do
label(field.method_name, field.label, :class => 'control-label') +
(field.nested_form ? field_for(field) : input_for(field))
end
end
else
- (field.nested_form ? field_for(field) : input_for(field))
+ (field.nested_form ? field_for(field) : input_for(field))
end
end
View
3 lib/rails_admin/config/fields/types/string.rb
@@ -11,8 +11,7 @@ class String < RailsAdmin::Config::Fields::Base
register_instance_option(:html_attributes) do
{
:maxlength => length,
- :size => [50, length.to_i].min,
- :required => required?
+ :size => [50, length.to_i].min
}
end
View
8 spec/integration/config/edit/rails_admin_config_edit_spec.rb
@@ -273,6 +273,7 @@ class HelpTest < Tableless
visit new_path(:model_name => "help_test")
find("#help_test_name_field .help-block").should have_content("Length of 1-49.")
end
+
end
it "should have accessor for its fields" do
@@ -329,12 +330,6 @@ class HelpTest < Tableless
should have_selector("label", :text => "Manager (STRING)")
should have_selector("label", :text => "Ballpark (STRING)")
end
-
- it 'should be required' do
- visit new_path(:model_name => "team")
- should have_selector '.required#team_manager_field'
- find('.required#team_manager_field input#team_manager')['required'].should_not be_blank
- end
end
describe "items' fields" do
@@ -894,6 +889,7 @@ class HelpTest < Tableless
end
end
+
describe "fields which are nullable and have AR validations", :active_record => true do
it "should be required" do

0 comments on commit 7cff5b1

Please sign in to comment.
Something went wrong with that request. Please try again.