Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Validations change label tags and add a tip about the message

  • Loading branch information...
commit ac98cbc606d07538698dedc1382fabf4aed99478 1 parent 8e6f1ac
@yawningman yawningman authored
View
15 app/views/sports_person/determine_ideal_weight.html.erb
@@ -4,12 +4,15 @@
:url => {:action => :determine_ideal_weight},
:builder => AjaxFormBuilder do |form| %>
- <div class="adjacent_form_fields">
- <p>
- <%= form.label :gender %>
- <%= form.select :gender, Gender.all %>
- </p>
- </div>
+ <p>
+ <%= form.label :gender %>
+
+ <%= form.radio_button :gender, Gender.male %>
+ <%= label_tag :sports_person_gender_male, Gender.male.capitalize, :class => :inline_label %>
+
+ <%= form.radio_button :gender, Gender.female %>
+ <%= label_tag :sports_person_gender_female, Gender.female.capitalize, :class => :inline_label %>
+ </p>
<p>
<%= form.label :height %>
View
12 config/initializers/validation_form_fields.rb
@@ -1,6 +1,7 @@
ActionView::Base.field_error_proc = Proc.new{|html_tag, instance|
error_message = instance.error_message
error_style = "field_with_errors"
+
if html_tag =~ /<(label)[^>]+class=/
style_attribute = html_tag =~ /class=['"]/
html_tag.insert(style_attribute + 7, "#{error_style}; ")
@@ -9,17 +10,16 @@
html_tag[first_whitespace] = " class='#{error_style}' "
end
-
if html_tag =~ /<(label)/
first_whitespace = html_tag =~ /\s/
- html_tag[first_whitespace] = " title='#{error_message}' "
+ html_tag[first_whitespace] = " title=\"#{error_message}\" "
end
tipsy_script = "<script type='text/javascript' charset='utf-8'>
- $(document).ready( function() {
- $('label').tipsy({gravity: 'nw'});
- });
+ $(document).ready( function() {
+ $('label[class=\"field_with_errors\"]').tipsy({gravity: 'w'});
+ });
</script>"
-
+
html_tag + tipsy_script.html_safe
}
View
16 public/stylesheets/application.css
@@ -14,11 +14,17 @@ body {
}
label {
- display: block;
+ display: table;
margin-bottom: 5px;
font-weight: bold;
+ width: auto;
}
+ .inline_label{
+ font-weight: normal;
+ display: inline;
+ margin-right: 20px;
+ }
input[type=text]{
padding-left: 5px;
@@ -31,6 +37,7 @@ input[type=text]{
a, a:visited { color: #06A; }
a:hover { color: #09F; }
+
#header {
-webkit-box-shadow: #999 0px 4px 8px 0px;
-moz-box-shadow: #999 0px 4px 8px 0px;
@@ -99,7 +106,11 @@ a:hover { color: #09F; }
.adjacent_form_fields p{
float: left;
}
-
+
+ .required_field{
+ background-color: #FFC300;
+ }
+
#daily_need {
border: solid 1px #DDD;
margin-top: 10px;
@@ -112,6 +123,7 @@ a:hover { color: #09F; }
.field_with_errors {
background-color: #F97703;
+ border: solid 1px #DDD;
padding: 5px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
View
4 public/stylesheets/form_fields.css
@@ -1,3 +1,7 @@
#sports_person_weight{
width: 50px;
+}
+
+#sports_person_height{
+ width: 50px;
}
View
2  public/stylesheets/tipsy.css
@@ -1,5 +1,5 @@
.tipsy { padding: 5px; font-size: 10px; background-repeat: no-repeat; }
- .tipsy-inner { padding: 5px 8px 4px 8px; background-color: #F97703; color: white; max-width: 200px; text-align: center; }
+ .tipsy-inner { padding: 5px 8px 4px 8px; background-color: #F97703; border: solid 1px #616161; color: white; max-width: 200px; text-align: center; }
.tipsy-inner { -moz-border-radius:3px; -webkit-border-radius:3px; }
.tipsy-north { background-position: top center; }
.tipsy-south { background-position: bottom center; }
Please sign in to comment.
Something went wrong with that request. Please try again.