search for: html_tag

Displaying 14 results from an estimated 14 matches for "html_tag".

2006 Jan 19
5
TIP: Using field_error_proc to add style attributes to form elements
..., and thought I''d share in case it''s useful to anyone else. This is handy if you don?t want to wrap your input elements inside a div when an error occurs, but instead want to add some sort of CSS style to fields with errors: ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| msg = instance.error_message error_style = "background-color: #f2afaf" if html_tag =~ /<(input|textarea|select)[^>]+style=/ style_attribute = html_tag =~ /style=[''"]/ html_tag.insert(style_attribute + 7, "#{error_style}; ") el...
2006 Feb 24
5
Changing default behavior of fieldWithErrors
Hi! The topic can be a bit misleading, because it may suggest that i want to change css style. What i''d like to change is that normally, when there''s an error, rails creates a div element with the fieldWithErrors class as the parent of the input. I''d like to change this behavior, so the input element itself will have this class added to its current classes and
2006 Mar 25
7
Overriding <div class="fieldWithErrors">
Does anyone know how to override the <div class="fieldWithErrors"> behaviour when a form field is incorrect? Thanks, Dan
2007 Apr 09
4
How do i switch off error wrapping for a specific field?
...g the FormHelper methods. As error_wrapping is a method in InstanceTag (and not of FormHelper), it is pretty hard to have a FormBuilder change its behaviour. One possibility is to define def initialize(object_name, object, template, options, proc) ActionView::Base.field_error_proc = lambda do |html_tag, instance| html_tag end super(object_name, object, template, options, proc) end which works, but i consider it an unclean solution (as it would change the error_proc for the whole interpreter run)....
2010 Oct 01
8
field_with_errors.
If a model doesn''t pass validation the field in the view is put under a <div class="field_with_errors">. But who create that div? field_text helper do it? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2009 Jun 25
4
standard ActiveRecord validation message
in testing my app I just use the validations validates_presence_of :first_name, :last_name, :email validates_presence_of :academy, :message => "You must select an Academy" validates_presence_of :role, :message => "You must select a role" standard error_messages are fine for most of my fields , resulting in : 5 errors prohibited this data from being saved There
2006 Mar 26
1
How to override generated in validation html code?
Hi, I would like to ask how to override validation functionality in RoR? In active_record_helper.rb class there is "hardcoded" default html generated durning validation. If I will use {code:ruby} validates_presence_of :summary, :description {code} in my model class, there is html generated: {code:html} <div class="errorExplanation"
2008 Jul 06
1
ActionView::Base.field_error_proc not getting an error field
...a blank form, I get all errors detected during User model validation, which is fine... BUT ActionView::Base.field_error_proc doesn''t get the role_name error, so I cannot change the style of the select I checked it , debugging the proc : ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| debugger .. I just get the html_tag for email and last_name, never for role_name ... what''s wrong ? thanks for your lights .. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Ra...
2006 Feb 13
3
Getting Rid of Error Divs around fields that have errors
Is there a way to get rid of the divs around an error field. These divs are causing me headaches. Any suggestions :-)? John Kopanas http://www.kopanas.com ===================================================================== http://www.soen.info - source of the freshest software engineering information on the net http://cusec.soen.info - software engineering conference
2008 Dec 11
2
uninitialized constant ActionVie
Hello I am trying to transform my web app into a 2.2 ready app, in my config/environment.rb I wrote Rails::Initializer.run do |config| ..... # disabling the surrounding div if validation error ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| if html_tag.include?("class=") html_tag.sub(%r{(class=["''])}, ''\1invalid '') else html_tag.sub(%r{(<[^ ]+ )}, ''\1class="invalid" '') end end .. end BUT running the console I get an error :...
2007 Nov 06
5
textarea fails on rows attribute
...in `tag!'' c:/ruby/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:140:in `each'' c:/ruby/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:140:in `tag!'' (eval):92:in `tag!'' c:/ruby/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:217:in `html_tag'' (eval):3:in `input'' C:/Documents and Settings/djberge/workspace/cluri/cluri.rb:118:in `index'' c:/ruby/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:123:in `instance_eval'' c:/ruby/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:123:in `captu...
2010 Oct 06
0
Error customization problem.
...ot; validates_presence_of :zipcode,:message => "Zip Code cannot be blank." validates_presence_of :country,:message => "Country cannot be blank." end also in my environment file(environment.rb) #Customize errors config.action_view.field_error_proc = Proc.new do |html_tag, instance| if instance.error_message.kind_of?(Array) %{<div class="input">#{html_tag}</div><div class="error">&bull;#{[instance.error_message].join(''<br/>&bull;'')}</div>} else %{<div class="input&q...
2010 Sep 23
7
errors.add, setting the whole message
Hi all. I have an attribute, job_role_id_short, that is being set in a form. This field has a custom validation on it, which does this if it fails: self.errors.add(:job_role_id_short, "cannot be blank") I want to add the error onto the attribute, so that the form builder will wrap the field in a fieldWithErrors div. However, the error it generates says "Job Role Short cannot
2010 Dec 14
4
Custom form error messages
...to override in order to be able to have the error message of each field in front of the input field? I haven''t been able to find anything similar on google. All I''ve found is how to override the container around the input field. ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| "<span class=\"fieldWithErrors\">#{html_tag}</span>" } Or in here do we have access of the error message of the current field? Greg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups...