% reference = reference_question.response(@answer_sheet) %>
<% reference ||= ReferenceSheet.new %>
<% css_class = reference_question.required?(@answer_sheet) ? 'required' : '' %>
<% email_css_class = reference_question.required?(@answer_sheet) ? 'required validate-email' : '' %>
<% phone_css_class = reference_question.required?(@answer_sheet) ? 'required validate-phone' : '' %>
<%#= hidden_field_tag "reference[#{reference.id}]", :class => reference_question.required? && !reference.email_sent? ? 'required' : '' %>
" class="desc">First Name
<%= text_field_tag "reference[#{reference.id}][first_name]", reference.first_name, :class => "text #{css_class}", :id => "name_#{reference.id}", :readonly => !@answer_sheet.try(:can_change_references?), :disabled => !@answer_sheet.try(:can_change_references?) %>
" class="desc">Last Name
<%= text_field_tag "reference[#{reference.id}][last_name]", reference.last_name, :class => "text #{css_class}", :id => "name_#{reference.id}", :readonly => !@answer_sheet.try(:can_change_references?), :disabled => !@answer_sheet.try(:can_change_references?) %>
" class="desc">Relationship to You
<%= text_field_tag "reference[#{reference.id}][relationship]", reference.relationship, :class => "text #{css_class}", :id => "name_#{reference.id}", :readonly => !@answer_sheet.try(:can_change_references?), :disabled => !@answer_sheet.try(:can_change_references?) %>
" class="desc">E-mail
<% if (!reference.email.blank?) %>Please be aware that any changes to this email address after your reference has started filling out their form will cause their answers to be lost.
<% end %>
<%= text_field_tag "reference[#{reference.id}][email]", reference.email, :class => "text #{email_css_class}", :id => "email_#{reference.id}", :readonly => !@answer_sheet.try(:can_change_references?), :disabled => !@answer_sheet.try(:can_change_references?) %>
" class="desc">Phone
<%= text_field_tag "reference[#{reference.id}][phone]", reference.phone, :class => "text #{phone_css_class}", :id => "phone_#{reference.id}", :readonly => !@answer_sheet.try(:can_change_references?), :disabled => !@answer_sheet.try(:can_change_references?) %>
An invitation will be sent to this reference when you submit your application. If you would
like to get a head start, please feel free to click 'Send Email Invitation' below.
If you already submitted your application and have returned to update your reference information - you must click "Send Email Invitation" after you
have edited the information in order for your reference to receive another email.
<%= link_to('Send Email Invitation', @answer_sheet ? send_reference_invite_answer_sheet_path(@answer_sheet, :reference_id => reference.id) : '#', :class => 'reference_send_invite') %>
Invitation last sent: <% if reference.email_sent_at.nil? -%>Never<% else %><%= reference.email_sent_at.strftime("%m/%d/%Y @ %I:%M%p") %><% end %>