11155
(-- --)
August 28, 2011, 5:01pm
1
Hi,
Instead of having on the labels the field name I would like to change it
some customized values.
How can I change that ?
Regards
%= form_for(@client_workout ) do |f| %>
<div class="field">
<%= f.label :client_name %><br />
<%= f.text_field :client_name %>
</div>
<div class="field">
<%= f.label :trainer %><br />
<%= f.text_field :trainer %>
</div>
<div class="field">
<%= f.label :duration_min %><br />
<%= f.text_field :duration_min %>
</div>
<div class="field">
<%= f.label :date_of_workout %><br />
<%= f.date_select :date_of_workout %>
</div>
<div class="field">
<%= f.label :paid_amount %><br />
<%= f.text_field :paid_amount %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Noel2
(Noel)
August 28, 2011, 5:44pm
2
<%= f.label "My label" %><br />
<%= f.label "My label" %><br />
no
f.label :field, "my name"
else
object = record_or_name_or_array
name = "#{object_name}#{index}[#{ActiveModel::Naming.singular(object)}]"
args.unshift(object)
end
@template.fields_for(name, *args, &block)
end
def label(method, text = nil, options = {}, &block)
@template.label(@object_name, method, text, objectify_options(options), &block)
end
def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
@template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
end
def radio_button(method, tag_value, options = {})
@template.radio_button(@object_name, method, tag_value, objectify_options(options))
end
tom
Adam22
(Adam)
August 28, 2011, 5:54pm
4
I always wondered, is there a way you can change the f.label at a
model label so regardless of where its used it always has the updated
label? is it somewhere in the localization file? or does this just
indicate for rails to have a best guess at what it is. I tried
defining them in a language file once but it never seemed to pick them
up.