Created
February 10, 2012 21:23
-
-
Save prathe/1792984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @timesheet, :builder => TimesheetFormBuilder do |timesheet_form| %> | |
<%= timesheet_form.fields_for :worklogs do |worklog_form| %> | |
<%= worklog_form.text_field :monday %> | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimesheetFormBuilder < ActionView::Helpers::FormBuilder | |
def text_field(method, opts) | |
#Get a reference to the model object | |
object = @template.instance_variable_get("@#{@object_name}") | |
value = object.send(method) | |
(opts ||= {}).merge!(value: value + 'h') | |
super(method, opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment