Skip to content

Commit 7cff5b1

Browse files
committed
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.
1 parent 1102806 commit 7cff5b1

File tree

5 files changed

+11
-23
lines changed

5 files changed

+11
-23
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ tmp/**/*
2929
.idea/*.xml
3030
.sass-cache
3131
nbproject
32-
.DS_Store

app/assets/stylesheets/rails_admin/base/theming.css.scss

+4-10
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ body.rails_admin {
3535
.control-group .hidden_type {
3636
display:none;
3737
}
38-
38+
3939
legend {
4040
cursor:pointer;
4141
i {
4242
vertical-align: inherit !important;
4343
}
4444
}
45-
45+
4646
&.denser {
4747
.controls .nav {
4848
margin-bottom:5px;
@@ -67,12 +67,6 @@ body.rails_admin {
6767
.control-group {
6868
margin: 0px;
6969
padding-top:15px;
70-
71-
&.required {
72-
.control-label {
73-
font-weight:bold;
74-
}
75-
}
7670
}
7771
.control-label {
7872
width:145px;
@@ -81,7 +75,7 @@ body.rails_admin {
8175
margin-bottom:0px;
8276
}
8377
}
84-
78+
8579
/* We want input size to be used, unfixate input width */
8680
input, textarea {
8781
width:auto;
@@ -101,7 +95,7 @@ body.rails_admin {
10195
&:hover>.remove_nested_fields {
10296
display:block;
10397
}
104-
98+
10599
border-left:5px solid $blue;
106100
padding-left:5px;
107101
fieldset {

app/helpers/rails_admin/form_builder.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def generate(options = {})
1414
if options[:nested_in]
1515
action = :nested
1616
elsif @template.request.format == 'text/javascript'
17-
action = :modal
17+
action = :modal
1818
else
1919
action = options[:action]
2020
end
21-
21+
2222
groups = options[:model_config].send(action).with(:form => self, :object => @object, :view => @template).visible_groups
2323

2424
object_infos +
@@ -45,13 +45,13 @@ def field_wrapper_for field, nested_in
4545
# do not show nested field if the target is the origin
4646
unless field.inverse_of.presence && field.inverse_of == nested_in &&
4747
@template.instance_variable_get(:@model_config).abstract_model == field.associated_model_config.abstract_model
48-
@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
48+
@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
4949
label(field.method_name, field.label, :class => 'control-label') +
5050
(field.nested_form ? field_for(field) : input_for(field))
5151
end
5252
end
5353
else
54-
(field.nested_form ? field_for(field) : input_for(field))
54+
(field.nested_form ? field_for(field) : input_for(field))
5555
end
5656
end
5757

lib/rails_admin/config/fields/types/string.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class String < RailsAdmin::Config::Fields::Base
1111
register_instance_option(:html_attributes) do
1212
{
1313
:maxlength => length,
14-
:size => [50, length.to_i].min,
15-
:required => required?
14+
:size => [50, length.to_i].min
1615
}
1716
end
1817

spec/integration/config/edit/rails_admin_config_edit_spec.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class HelpTest < Tableless
273273
visit new_path(:model_name => "help_test")
274274
find("#help_test_name_field .help-block").should have_content("Length of 1-49.")
275275
end
276+
276277
end
277278

278279
it "should have accessor for its fields" do
@@ -329,12 +330,6 @@ class HelpTest < Tableless
329330
should have_selector("label", :text => "Manager (STRING)")
330331
should have_selector("label", :text => "Ballpark (STRING)")
331332
end
332-
333-
it 'should be required' do
334-
visit new_path(:model_name => "team")
335-
should have_selector '.required#team_manager_field'
336-
find('.required#team_manager_field input#team_manager')['required'].should_not be_blank
337-
end
338333
end
339334

340335
describe "items' fields" do
@@ -894,6 +889,7 @@ class HelpTest < Tableless
894889
end
895890
end
896891

892+
897893
describe "fields which are nullable and have AR validations", :active_record => true do
898894

899895
it "should be required" do

0 commit comments

Comments
 (0)