<commit_before><%
begin
  remote_controller = active_scaffold_controller_for(column.association.klass)
rescue ActiveScaffold::ControllerNotFound
  remote_controller = nil
end

show_add_existing = column_show_add_existing(column)
show_add_new = column_show_add_new(column, associated, @record)

return unless show_add_new or show_add_existing

edit_associated_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :associated_id => '--ID--', :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_existing
add_new_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_new

-%>
<div class="footer-wrapper">
  <div class="footer">
    <% if show_add_new -%>
    <% add_label = column.plural_association? ? as_(:create_another, :model => column.association.klass.model_name.human) : as_(:replace_with_new) -%>
    <%= button_to_function add_label, "new Ajax.Request(#{add_new_url.to_json}, {asynchronous: true, method: 'get', evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}})" %>
    <% end -%>

    <%= '|' if show_add_new and show_add_existing %>

    <% if show_add_existing -%>
      <% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
        <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "new Ajax.Request(#{edit_associated_url.to_json}.sub('--ID--', id), {asynchronous: true, evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}});" -%>
      <% else -%>
        <% select_options = options_for_select(options_for_association(column.association)) -%>
        <%= select_tag 'associated_id', '<option value="">' + as_(:_select_) + '</option>' + select_options %>
        <%= button_to_function as_(:add_existing), "new Ajax.Request(#{edit_associated_url.to_json}.sub('--ID--', Element.previous(this).value), {asynchronous: true, method: 'get', evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}})" %>
      <% end -%>
    <% end -%>
  </div>
</div>

<script type="text/javascript"><commit_msg>Bugfix: use html_safe to display options in existing records select box<commit_after><%
begin
  remote_controller = active_scaffold_controller_for(column.association.klass)
rescue ActiveScaffold::ControllerNotFound
  remote_controller = nil
end

show_add_existing = column_show_add_existing(column)
show_add_new = column_show_add_new(column, associated, @record)

return unless show_add_new or show_add_existing

edit_associated_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :associated_id => '--ID--', :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_existing
add_new_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_new

-%>
<div class="footer-wrapper">
  <div class="footer">
    <% if show_add_new -%>
    <% add_label = column.plural_association? ? as_(:create_another, :model => column.association.klass.model_name.human) : as_(:replace_with_new) -%>
    <%= button_to_function add_label, "new Ajax.Request(#{add_new_url.to_json}, {asynchronous: true, method: 'get', evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}})" %>
    <% end -%>

    <%= '|' if show_add_new and show_add_existing %>

    <% if show_add_existing -%>
      <% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
        <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "new Ajax.Request(#{edit_associated_url.to_json}.sub('--ID--', id), {asynchronous: true, evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}});" -%>
      <% else -%>
        <% select_options = options_for_select(options_for_association(column.association)) -%>
        <%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
        <%= button_to_function as_(:add_existing), "new Ajax.Request(#{edit_associated_url.to_json}.sub('--ID--', Element.previous(this).value), {asynchronous: true, method: 'get', evalScripts: true, onFailure: function(){ActiveScaffold.report_500_response(#{active_scaffold_id.to_json})}})" %>
      <% end -%>
    <% end -%>
  </div>
</div>

<script type="text/javascript">
{'fraction_non_alphanumeric': 0.1589652448657188, 'fraction_numerical': 0.0035545023696682463, 'mean_word_length': 6.164073550212164, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5155644', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1652, 'n_words': 281}