21 May 03:17
Re: help needed with where and how best to set a param
From: AndyV <AndyVanasse@...>
Subject: Re: help needed with where and how best to set a param
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-21 01:17:01 GMT
Subject: Re: help needed with where and how best to set a param
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-21 01:17:01 GMT
Yes, you're in the right ballpark. There are a few different ways you
could go.
First, I'd recommend that you piggyback on that 'option' hash. I'd
probably use a value like 'required_field' or something like that.
From that point you have the options. One way to approach it would be
to use option[:required_field] to add a css class to the field.
@template.capture do
locals = {
:element => yield,
:label => label(field, options[:label], :class=>
options[:required_field] ? 'required' : 'label')
}
Another option would be to just add a '*' to the label. Right before
the call to 'build_shell':
options[:label] ||= field.to_s.humanize # default value for label if
none was provide
options[:label] << " *" if options[:required_field] # Add asterisk if
requred
On May 20, 4:11 pm, Becca Girl <rails-mailing-l...@...>
wrote:
> AndyV wrote:
>
> If you follow the logic presented in the recipe you should be
>
> > able to extend it to denote required fields, too. You should be able
> > to provide a 'required' attribute in a similar way they provide the
> > override for the label.
>
> I'm still learning my way around RoR. I see this in the DRY Forms
> helper code:
>
> @template.capture do
> locals = {
> :element => yield,
> :label => label(field, options[:label])
> }
>
> Would I add something there to designate that I need the required fields
> to look a little different?
>
> Here's the form field template and how it's displayed:
> <span class="label">
> <%= label %>
> </span>
>
> So if it's required, I want to add a red asterisk.
>
> Thanks for helping a newbie.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
RSS Feed