I have a form with the following field interaction rules.
Given checkbox A,
text field B
text field C
If checkbox A is checked then make text field C equal to the value of
text field B and disable field C.
If checkbox A is unchecked then enable field C.
In order to display a form where I’m manipulating an already existing
object, I have something like this in my RHTML template to display text
<%= (@obj.field_B == @obj.field_C) ?
text_field(:obj, ‘field_C’, :disabled => ‘true’) :
text_field(:obj, ‘field_C’, :disabled => ‘false’) %>
Should I put this logic in a helper so as to simplify my template and
keep this small bit of business logic out of it?
function in an onLoad() handler?
Should I use an onLoad handler that executes an AJAX call to handle
setting up these fields correctly - then I could just add AJAX calls to
default other fields as well? (seems a little excessive to me).