Forum: Ruby on Rails Should ActionView's label tag helper be extended to accept a _complementary_ content block ?

Posted by Luis Reis (Guest)
on 2013-01-22 12:33
(Received via mailing list)
Hi,

Sometimes it is useful to use label with both a contained label and
supplied content, eg, in Devise's default registration edit view this is
the supplied code for passwords:

[...]
  <div><%= f.label :password %> <i>(leave blank if you don't want to 
change
it)</i><br />
  <%= f.password_field :password, :autocomplete => "off" %></div>
[...]

It would be useful for formatting if this code could be:

[...]
  <div><%= f.label :password, :add_content => true do %> <i>(leave blank 
if
you don't want to change it)</i><% end %><br />
  <%= f.password_field :password, :autocomplete => "off" %></div>
[...]

Generating the following html:

[...]
  <div><label for="user_password"> <i>(leave blank if you don't want to
change it)</i></label><br />
[...]

Currently using a method (:password) is mutually exclusive with 
supplying a
block.

So, in other words, if I submit a patch to do this, would it be accepted 
?

Another alternative would be to have a label_content helper returning 
the
calculated content.

Thanks,
Cheers,
Luis Reis
Posted by Frederick Cheung (Guest)
on 2013-01-22 12:38
(Received via mailing list)
On Monday, January 21, 2013 11:42:29 PM UTC, Luis Reis wrote:
>
>
> Currently using a method (:password) is mutually exclusive with supplying
> a block.
>
> You sure ? It's documented as allowing that and a 2 second test on one of
my apps seemed to work

Fred
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.